Sha256: 4bf965d7939b4080863c3358c91eca7ee488c3e1785d043f4beca757d8f00f24

Contents?: true

Size: 726 Bytes

Versions: 3

Compression:

Stored size: 726 Bytes

Contents

# frozen_string_literal: true

module ACE
  class Error < RuntimeError
    attr_reader :kind, :details, :issue_code, :error_code

    def initialize(msg, kind, details = nil, issue_code = nil)
      super(msg)
      @kind = kind
      @issue_code = issue_code
      @details = details || {}
      @error_code ||= 1
    end

    def msg
      message
    end

    def to_h
      Error.to_h(msg, kind, details, issue_code)
    end

    def to_json(opts = nil)
      to_h.to_json(opts)
    end

    def self.to_h(message, kind, details = nil, issue_code = nil)
      h = { 'kind' => kind,
            'msg' => message,
            'details' => details }
      h['issue_code'] = issue_code if issue_code
      h
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
agentless-catalog-executor-1.1.0 lib/ace/error.rb
agentless-catalog-executor-1.0.0 lib/ace/error.rb
agentless-catalog-executor-0.10.0 lib/ace/error.rb