Sha256: 9942f6f88b9a7beebc7b518cfd9bed01ab95814a5f5cffc193e79735168589f1

Contents?: true

Size: 808 Bytes

Versions: 3

Compression:

Stored size: 808 Bytes

Contents

require "json"

module Kharon
  module Errors

    # Standard exception raised in case the exceptions are used, and there is an error in the validation.
    # @author Vincent Courtois <courtois.vincent@outlook.com>
    class Validation < Exception

      # @!attribute [rw] error_hash
        # @return [Hash] the description of the encountered error as a Hash.
      attr_accessor :error_hash

      # Constructor of the class.
      # @param [Hash] error_hash the description of the encountered error as a Hash.
      def initialize(error_hash)
        @error_hash = error_hash
      end

      # Generates a JSON version of the encountered error description hash.
      # @return [String] the JSON representation of an error.
      def message
        JSON.generate(error_hash)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
kharon-1.1.1 lib/kharon/errors/validation.rb
kharon-1.1.0 lib/kharon/errors/validation.rb
kharon-1.0.0 lib/kharon/errors/validation.rb