Exception: Pandocomatic::PandocomaticError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/pandocomatic/error/pandocomatic_error.rb

Overview

General pandocomatic error

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type = :unknown, error = nil, data = nil) ⇒ PandocomaticError

Create a new PandocomaticError

Parameters:

  • type (Symbol = :unknown) (defaults to: :unknown)

    the type of error, defaults to :unknown

  • error (Error = nil) (defaults to: nil)

    the underlying error, optional

  • data (Object = nil) (defaults to: nil)

    extra information attached to this PandocomaticError, if any; optional



43
44
45
46
47
48
# File 'lib/pandocomatic/error/pandocomatic_error.rb', line 43

def initialize(type = :unknown, error = nil, data = nil)
  super(type.to_s.gsub('_', ' ').capitalize)
  @type = type
  @error = error
  @data = data
end

Instance Attribute Details

#dataObject

Returns attached data, if any.

Returns:

  • (Object)

    attached data, if any



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/pandocomatic/error/pandocomatic_error.rb', line 34

class PandocomaticError < StandardError
  attr_reader :type, :error, :data

  # Create a new PandocomaticError
  #
  # @param type [Symbol = :unknown] the type of error, defaults to :unknown
  # @param error [Error = nil] the underlying error, optional
  # @param data [Object = nil] extra information attached to this
  #   PandocomaticError, if any; optional
  def initialize(type = :unknown, error = nil, data = nil)
    super(type.to_s.gsub('_', ' ').capitalize)
    @type = type
    @error = error
    @data = data
  end

  # Has this PandocomaticError an underlying error?
  #
  # @return [Boolean]
  def error?
    !@error.nil?
  end

  # Has this PandocomaticError extra information associated to it?
  #
  # @return [Boolean]
  def data?
    !@data.nil?
  end

  # Print this error.
  def print
    ErrorPrinter.new(self).print
  end

  # Show this error
  #
  # @return [String] a string representation of this PandocomaticError
  def show
    ErrorPrinter.new(self).to_s
  end
end

#errorError

Returns the underlying error, if any.

Returns:

  • (Error)

    the underlying error, if any



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/pandocomatic/error/pandocomatic_error.rb', line 34

class PandocomaticError < StandardError
  attr_reader :type, :error, :data

  # Create a new PandocomaticError
  #
  # @param type [Symbol = :unknown] the type of error, defaults to :unknown
  # @param error [Error = nil] the underlying error, optional
  # @param data [Object = nil] extra information attached to this
  #   PandocomaticError, if any; optional
  def initialize(type = :unknown, error = nil, data = nil)
    super(type.to_s.gsub('_', ' ').capitalize)
    @type = type
    @error = error
    @data = data
  end

  # Has this PandocomaticError an underlying error?
  #
  # @return [Boolean]
  def error?
    !@error.nil?
  end

  # Has this PandocomaticError extra information associated to it?
  #
  # @return [Boolean]
  def data?
    !@data.nil?
  end

  # Print this error.
  def print
    ErrorPrinter.new(self).print
  end

  # Show this error
  #
  # @return [String] a string representation of this PandocomaticError
  def show
    ErrorPrinter.new(self).to_s
  end
end

#typeSymbol

Returns type of error.

Returns:

  • (Symbol)

    type of error



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/pandocomatic/error/pandocomatic_error.rb', line 34

class PandocomaticError < StandardError
  attr_reader :type, :error, :data

  # Create a new PandocomaticError
  #
  # @param type [Symbol = :unknown] the type of error, defaults to :unknown
  # @param error [Error = nil] the underlying error, optional
  # @param data [Object = nil] extra information attached to this
  #   PandocomaticError, if any; optional
  def initialize(type = :unknown, error = nil, data = nil)
    super(type.to_s.gsub('_', ' ').capitalize)
    @type = type
    @error = error
    @data = data
  end

  # Has this PandocomaticError an underlying error?
  #
  # @return [Boolean]
  def error?
    !@error.nil?
  end

  # Has this PandocomaticError extra information associated to it?
  #
  # @return [Boolean]
  def data?
    !@data.nil?
  end

  # Print this error.
  def print
    ErrorPrinter.new(self).print
  end

  # Show this error
  #
  # @return [String] a string representation of this PandocomaticError
  def show
    ErrorPrinter.new(self).to_s
  end
end

Instance Method Details

#data?Boolean

Has this PandocomaticError extra information associated to it?

Returns:

  • (Boolean)


60
61
62
# File 'lib/pandocomatic/error/pandocomatic_error.rb', line 60

def data?
  !@data.nil?
end

#error?Boolean

Has this PandocomaticError an underlying error?

Returns:

  • (Boolean)


53
54
55
# File 'lib/pandocomatic/error/pandocomatic_error.rb', line 53

def error?
  !@error.nil?
end

Print this error.



65
66
67
# File 'lib/pandocomatic/error/pandocomatic_error.rb', line 65

def print
  ErrorPrinter.new(self).print
end

#showString

Show this error

Returns:

  • (String)

    a string representation of this PandocomaticError



72
73
74
# File 'lib/pandocomatic/error/pandocomatic_error.rb', line 72

def show
  ErrorPrinter.new(self).to_s
end