Exception: XZ::LZMAError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/xz/lib_lzma.rb

Overview

The class of the error that this library raises.

Class Method Summary collapse

Class Method Details

.raise_if_necessary(val) ⇒ Object

Raises an appropriate exception if val isn’t a liblzma success code.



165
166
167
168
169
170
171
172
173
174
175
# File 'lib/xz/lib_lzma.rb', line 165

def self.raise_if_necessary(val)
  case val
  when LibLZMA::LZMA_MEM_ERROR      then raise(self, "Couldn't allocate memory!")
  when LibLZMA::LZMA_MEMLIMIT_ERROR then raise(self, "Decoder ran out of (allowed) memory!")
  when LibLZMA::LZMA_FORMAT_ERROR   then raise(self, "Unrecognized file format!")
  when LibLZMA::LZMA_OPTIONS_ERROR  then raise(self, "Invalid options passed!")
  when LibLZMA::LZMA_DATA_ERROR     then raise(self, "Archive is currupt.")
  when LibLZMA::LZMA_BUF_ERROR      then raise(self, "Buffer unusable!")
  when LibLZMA::LZMA_PROG_ERROR     then raise(self, "Program error--if you're sure your code is correct, you may have found a bug in liblzma.")
  end
end