Class: GLExceptionNotifier
- Inherits:
-
Object
- Object
- GLExceptionNotifier
- Defined in:
- lib/gl_exception_notifier.rb
Constant Summary collapse
- CONTEXT_TYPES =
%i[extra_context tags_context user_context].freeze
Class Method Summary collapse
- .add_context(type, context) ⇒ Object
- .breadcrumbs(data:, message: nil) ⇒ Object
- .call(*args) ⇒ Object
- .last_breadcrumb ⇒ Object
Class Method Details
.add_context(type, context) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/gl_exception_notifier.rb', line 19 def add_context(type, context) unless CONTEXT_TYPES.include?(type) raise ArgumentError, 'type paramater must be one of: :extra_context, :tags_context, :user_context' end raise ArgumentError, 'contexts must be a hash' unless context.is_a?(Hash) case type when :user_context error_client.set_user(context) when :tags_context error_client.(context) when :extra_context error_client.set_extras(context) end end |
.breadcrumbs(data:, message: nil) ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/gl_exception_notifier.rb', line 38 def (data:, message: nil) raise ArgumentError, 'data must be a hash' unless data.is_a?(Hash) raise ArgumentError, 'when providing a message, it must be a string' if && !.is_a?(String) crumb = .new(message:, data:) error_client.(crumb) crumb end |
.call(*args) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/gl_exception_notifier.rb', line 9 def call(*args) if exceptionable?(args.first) capture_exception(args) else (args) end end |
.last_breadcrumb ⇒ Object
47 48 49 |
# File 'lib/gl_exception_notifier.rb', line 47 def error_client.get_current_scope&.&.peek end |