Class: GraphitiGql::ExceptionHandler
- Inherits:
-
Object
- Object
- GraphitiGql::ExceptionHandler
- Defined in:
- lib/graphiti_gql/exception_handler.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#field ⇒ Object
readonly
Returns the value of attribute field.
Class Method Summary collapse
Instance Method Summary collapse
- #handle ⇒ Object
-
#initialize(err, obj, args, ctx, field) ⇒ ExceptionHandler
constructor
A new instance of ExceptionHandler.
- #log ⇒ Object
- #notify ⇒ Object
Constructor Details
#initialize(err, obj, args, ctx, field) ⇒ ExceptionHandler
Returns a new instance of ExceptionHandler.
19 20 21 22 23 24 25 26 |
# File 'lib/graphiti_gql/exception_handler.rb', line 19 def initialize(err, obj, args, ctx, field) @error = err @obj = obj @args = args @context = ctx @field = field @config = get_config(err) end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
3 4 5 |
# File 'lib/graphiti_gql/exception_handler.rb', line 3 def context @context end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
3 4 5 |
# File 'lib/graphiti_gql/exception_handler.rb', line 3 def error @error end |
#field ⇒ Object (readonly)
Returns the value of attribute field.
3 4 5 |
# File 'lib/graphiti_gql/exception_handler.rb', line 3 def field @field end |
Class Method Details
.register_exception(err, opts) ⇒ Object
10 11 12 |
# File 'lib/graphiti_gql/exception_handler.rb', line 10 def self.register_exception(err, opts) registry[err] = opts end |
Instance Method Details
#handle ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/graphiti_gql/exception_handler.rb', line 36 def handle notify if @config[:notify] != false log if @config[:log] != false = @config[:message] ? err. : code = @config[:code] || default_code raise GraphQL::ExecutionError.new(, extensions: { code: code }) end |
#log ⇒ Object
32 33 34 |
# File 'lib/graphiti_gql/exception_handler.rb', line 32 def log # noop end |
#notify ⇒ Object
28 29 30 |
# File 'lib/graphiti_gql/exception_handler.rb', line 28 def notify # noop end |