Sha256: 0d8a79484f8fb403852ba0b6d0a07f2135fde942607733ecbb9bcef90b5cd367

Contents?: true

Size: 935 Bytes

Versions: 6

Compression:

Stored size: 935 Bytes

Contents

module Mutations
  class ErrorArray
    def self.new_from_error_hash(errors)
      new(errors.collect do |key, values|
        ErrorAtom.new(key, values[:symbol], values)
      end)
    end
  end
end

module Hyperstack
  class AccessViolation < StandardError
    attr_accessor :details

    def initialize(message = nil, details = nil)
      super("Hyperstack::AccessViolation#{':' + message.to_s if message}")
      @details = details
    end

    def __hyperstack_on_error(operation, params, fmted_message)
      Hyperstack.on_error(operation, self, params, fmted_message)
    end
  end

  class Operation
    class ValidationException < Mutations::ValidationException
      def as_json(*)
        errors.as_json
      end

      def initialize(errors)
        unless errors.is_a? Mutations::ErrorHash
          errors = Mutations::ErrorArray.new_from_error_hash(errors)
        end
        super(errors)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
hyper-operation-1.0.alpha1.8 lib/hyper-operation/exception.rb
hyper-operation-1.0.alpha1.7 lib/hyper-operation/exception.rb
hyper-operation-1.0.alpha1.6 lib/hyper-operation/exception.rb
hyper-operation-1.0.alpha1.5 lib/hyper-operation/exception.rb
hyper-operation-1.0.alpha1.4 lib/hyper-operation/exception.rb
hyper-operation-1.0.alpha1.3 lib/hyper-operation/exception.rb