Class: ErrornotNotifier::Notice
- Inherits:
-
Object
- Object
- ErrornotNotifier::Notice
- Defined in:
- lib/errornot_notifier/notice.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
The action (if any) that was called in this request.
-
#api_key ⇒ Object
readonly
The API key for the project to which this notice should be sent.
-
#backtrace ⇒ Object
readonly
The backtrace from the given exception or hash.
-
#backtrace_filters ⇒ Object
readonly
See Configuration#backtrace_filters.
-
#cgi_data ⇒ Object
readonly
CGI variables such as HTTP_METHOD.
-
#component ⇒ Object
(also: #controller)
readonly
The component (if any) which was used in this request (usually the controller).
-
#environment_name ⇒ Object
readonly
The name of the server environment (such as “production”).
-
#error_class ⇒ Object
readonly
The name of the class of error (such as RuntimeError).
-
#error_message ⇒ Object
readonly
The message from the exception, or a general description of the error.
-
#exception ⇒ Object
readonly
The exception that caused this notice, if any.
-
#ignore ⇒ Object
readonly
See Configuration#ignore.
-
#ignore_by_filters ⇒ Object
readonly
See Configuration#ignore_by_filters.
-
#notifier_name ⇒ Object
readonly
The name of the notifier library sending this notice, such as “Errornot Notifier”.
-
#notifier_url ⇒ Object
readonly
A URL for more information about the notifier library sending this notice.
-
#notifier_version ⇒ Object
readonly
The version number of the notifier library sending this notice, such as “2.1.3”.
-
#parameters ⇒ Object
(also: #params)
readonly
A hash of parameters from the query string or post body.
-
#params_filters ⇒ Object
readonly
See Configuration#params_filters.
-
#project_root ⇒ Object
readonly
The path to the project that caused the error (usually RAILS_ROOT).
-
#session_data ⇒ Object
readonly
A hash of session data from the request.
-
#url ⇒ Object
readonly
The URL at which the error occurred (if any).
Instance Method Summary collapse
-
#[](method) ⇒ Object
Allows properties to be accessed using a hash-like syntax.
-
#ignore? ⇒ Boolean
Determines if this notice should be ignored.
-
#initialize(args) ⇒ Notice
constructor
A new instance of Notice.
-
#to_xml ⇒ Object
Converts the given notice to XML TODO: ErroNot specific, not transform to XML now, but in Hash.
Constructor Details
#initialize(args) ⇒ Notice
Returns a new instance of Notice.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/errornot_notifier/notice.rb', line 68 def initialize(args) self.args = args self.exception = args[:exception] self.api_key = args[:api_key] self.project_root = args[:project_root] self.url = args[:url] || rack_env(:url) self.notifier_name = args[:notifier_name] self.notifier_version = args[:notifier_version] self.notifier_url = args[:notifier_url] self.ignore = args[:ignore] || [] self.ignore_by_filters = args[:ignore_by_filters] || [] self.backtrace_filters = args[:backtrace_filters] || [] @params_filters = args[:params_filters] || [] self.parameters = args[:parameters] || action_dispatch_params || rack_env(:params) || {} self.component = args[:component] || args[:controller] || parameters['controller'] self.action = args[:action] || parameters['action'] self.environment_name = args[:environment_name] self.cgi_data = args[:cgi_data] || args[:rack_env] self.backtrace = Backtrace.parse(exception_attribute(:backtrace, caller), :filters => self.backtrace_filters) self.error_class = exception_attribute(:error_class) {|exception| exception.class.name } self. = exception_attribute(:error_message, 'Notification') do |exception| "#{exception.class.name}: #{exception.}" end also_use_rack_params_filters find_session_data clean_params clean_rack_request_data end |
Instance Attribute Details
#action ⇒ Object
The action (if any) that was called in this request
42 43 44 |
# File 'lib/errornot_notifier/notice.rb', line 42 def action @action end |
#api_key ⇒ Object
The API key for the project to which this notice should be sent
10 11 12 |
# File 'lib/errornot_notifier/notice.rb', line 10 def api_key @api_key end |
#backtrace ⇒ Object
The backtrace from the given exception or hash.
13 14 15 |
# File 'lib/errornot_notifier/notice.rb', line 13 def backtrace @backtrace end |
#backtrace_filters ⇒ Object
See Configuration#backtrace_filters
28 29 30 |
# File 'lib/errornot_notifier/notice.rb', line 28 def backtrace_filters @backtrace_filters end |
#cgi_data ⇒ Object
CGI variables such as HTTP_METHOD
22 23 24 |
# File 'lib/errornot_notifier/notice.rb', line 22 def cgi_data @cgi_data end |
#component ⇒ Object Also known as: controller
The component (if any) which was used in this request (usually the controller)
38 39 40 |
# File 'lib/errornot_notifier/notice.rb', line 38 def component @component end |
#environment_name ⇒ Object
The name of the server environment (such as “production”)
19 20 21 |
# File 'lib/errornot_notifier/notice.rb', line 19 def environment_name @environment_name end |
#error_class ⇒ Object
The name of the class of error (such as RuntimeError)
16 17 18 |
# File 'lib/errornot_notifier/notice.rb', line 16 def error_class @error_class end |
#error_message ⇒ Object
The message from the exception, or a general description of the error
25 26 27 |
# File 'lib/errornot_notifier/notice.rb', line 25 def @error_message end |
#exception ⇒ Object
The exception that caused this notice, if any
7 8 9 |
# File 'lib/errornot_notifier/notice.rb', line 7 def exception @exception end |
#ignore ⇒ Object
See Configuration#ignore
54 55 56 |
# File 'lib/errornot_notifier/notice.rb', line 54 def ignore @ignore end |
#ignore_by_filters ⇒ Object
See Configuration#ignore_by_filters
57 58 59 |
# File 'lib/errornot_notifier/notice.rb', line 57 def ignore_by_filters @ignore_by_filters end |
#notifier_name ⇒ Object
The name of the notifier library sending this notice, such as “Errornot Notifier”
60 61 62 |
# File 'lib/errornot_notifier/notice.rb', line 60 def notifier_name @notifier_name end |
#notifier_url ⇒ Object
A URL for more information about the notifier library sending this notice
66 67 68 |
# File 'lib/errornot_notifier/notice.rb', line 66 def notifier_url @notifier_url end |
#notifier_version ⇒ Object
The version number of the notifier library sending this notice, such as “2.1.3”
63 64 65 |
# File 'lib/errornot_notifier/notice.rb', line 63 def notifier_version @notifier_version end |
#parameters ⇒ Object Also known as: params
A hash of parameters from the query string or post body.
34 35 36 |
# File 'lib/errornot_notifier/notice.rb', line 34 def parameters @parameters end |
#params_filters ⇒ Object
See Configuration#params_filters
31 32 33 |
# File 'lib/errornot_notifier/notice.rb', line 31 def params_filters @params_filters end |
#project_root ⇒ Object
The path to the project that caused the error (usually RAILS_ROOT)
48 49 50 |
# File 'lib/errornot_notifier/notice.rb', line 48 def project_root @project_root end |
#session_data ⇒ Object
A hash of session data from the request
45 46 47 |
# File 'lib/errornot_notifier/notice.rb', line 45 def session_data @session_data end |
#url ⇒ Object
The URL at which the error occurred (if any)
51 52 53 |
# File 'lib/errornot_notifier/notice.rb', line 51 def url @url end |
Instance Method Details
#[](method) ⇒ Object
Allows properties to be accessed using a hash-like syntax
155 156 157 158 159 160 161 162 |
# File 'lib/errornot_notifier/notice.rb', line 155 def [](method) case method when :request self else send(method) end end |
#ignore? ⇒ Boolean
Determines if this notice should be ignored
144 145 146 147 |
# File 'lib/errornot_notifier/notice.rb', line 144 def ignore? ignored_class_names.include?(error_class) || ignore_by_filters.any? {|filter| filter.call(self) } end |
#to_xml ⇒ Object
Converts the given notice to XML TODO:
ErroNot specific, not transform to XML now,
but in Hash. need change name
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/errornot_notifier/notice.rb', line 108 def to_xml error = { 'message' => , 'raised_at' => Time.now, 'backtrace' => self.backtrace.lines} if url || controller || action || !parameters.blank? || !cgi_data.blank? || !session_data.blank? error['request'] = {'url' => url, 'component' => controller, 'action' => action} unless parameters.nil? || parameters.empty? error['request']['params'] = parameters end unless session_data.nil? || session_data.empty? error['session'] = session_data end unless cgi_data.nil? || cgi_data.empty? error['request']['cgi-data'] = cgi_data end error['environment'] = {'root' => project_root, 'name' => environment_name} end {'error' => error, 'api_key' => api_key, 'version' => '0.1.0'} end |