Class: Errordeck::Wrapper
- Inherits:
-
Object
- Object
- Errordeck::Wrapper
- Defined in:
- lib/errordeck/wrapper.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
Returns the value of attribute context.
-
#error_event ⇒ Object
readonly
Returns the value of attribute error_event.
-
#modules ⇒ Object
readonly
Returns the value of attribute modules.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#transaction ⇒ Object
readonly
Returns the value of attribute transaction.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #capture(exception, user = nil, tags = nil) ⇒ Object
-
#initialize ⇒ Wrapper
constructor
A new instance of Wrapper.
- #message(level, message, extra = nil) ⇒ Object
- #send_event ⇒ Object
- #set_action_context(env) ⇒ Object
- #set_request(env = nil) ⇒ Object
- #set_transaction(transaction = nil) ⇒ Object
- #tags_context=(tags) ⇒ Object
- #user_context=(user) ⇒ Object
Constructor Details
#initialize ⇒ Wrapper
Returns a new instance of Wrapper.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/errordeck/wrapper.rb', line 8 def initialize @error_event = nil @transaction = nil @request = nil @user = nil = nil = false @already_sent = false if Gem::Specification.respond_to?(:map) @modules = Gem::Specification.to_h do |spec| [spec.name, spec.version.to_s] end end @context = Context.context end |
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context.
5 6 7 |
# File 'lib/errordeck/wrapper.rb', line 5 def context @context end |
#error_event ⇒ Object (readonly)
Returns the value of attribute error_event.
6 7 8 |
# File 'lib/errordeck/wrapper.rb', line 6 def error_event @error_event end |
#modules ⇒ Object (readonly)
Returns the value of attribute modules.
6 7 8 |
# File 'lib/errordeck/wrapper.rb', line 6 def modules @modules end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
6 7 8 |
# File 'lib/errordeck/wrapper.rb', line 6 def request @request end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
6 7 8 |
# File 'lib/errordeck/wrapper.rb', line 6 def end |
#transaction ⇒ Object (readonly)
Returns the value of attribute transaction.
6 7 8 |
# File 'lib/errordeck/wrapper.rb', line 6 def transaction @transaction end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
6 7 8 |
# File 'lib/errordeck/wrapper.rb', line 6 def user @user end |
Instance Method Details
#capture(exception, user = nil, tags = nil) ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/errordeck/wrapper.rb', line 40 def capture(exception, user = nil, = nil) = false @error_event = generate_from_exception(exception) @error_event.user = user || @user @error_event. = || @error_event.request = @request @error_event end |
#message(level, message, extra = nil) ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/errordeck/wrapper.rb', line 49 def (level, , extra = nil) = true @error_event = generate_boxing_event(level, , extra) @error_event.user = @user @error_event. = @error_event.request = @request @error_event end |
#send_event ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/errordeck/wrapper.rb', line 24 def send_event return if @error_event.nil? && == true return if @already_sent uri = URI.parse("https://app.errordeck.com/api/#{config.project_id}/store") http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true request = Net::HTTP::Post.new(uri.request_uri, "Authorization" => "Bearer #{config.token}") request["Content-Type"] = "application/json" event_json = @error_event&.to_json response = http.request(request, event_json) @already_sent = true rescue StandardError => e raise Error, "Error sending issue to Errordeck: #{e.message}" end |
#set_action_context(env) ⇒ Object
58 59 60 61 |
# File 'lib/errordeck/wrapper.rb', line 58 def set_action_context(env) request_handler = RequestHandler.parse_from_rack_env(env) @request = Request.parse_from_request_handler(request_handler) end |
#set_request(env = nil) ⇒ Object
67 68 69 |
# File 'lib/errordeck/wrapper.rb', line 67 def set_request(env = nil) @request = Request.parse_from_rack_env(env) end |
#set_transaction(transaction = nil) ⇒ Object
63 64 65 |
# File 'lib/errordeck/wrapper.rb', line 63 def set_transaction(transaction = nil) @transaction = transaction end |
#tags_context=(tags) ⇒ Object
75 76 77 |
# File 'lib/errordeck/wrapper.rb', line 75 def () = end |
#user_context=(user) ⇒ Object
71 72 73 |
# File 'lib/errordeck/wrapper.rb', line 71 def user_context=(user) @user = user end |