Module: Ask::SolidErrors
- Defined in:
- lib/ask/solid_errors/client.rb,
lib/ask/solid_errors/context.rb,
lib/ask/solid_errors/version.rb,
lib/ask/solid_errors/error_guide.rb
Defined Under Namespace
Modules: Errors Classes: ClientProxy
Constant Summary collapse
- DESCRIPTION =
Human-readable description of the SolidErrors service context.
"SolidErrors — error tracking stored in your Rails database"- GEM_NAME =
Gem name for the SolidErrors tracker.
"solid_errors"- QUICK_START =
Quick-start Ruby code snippet for agents to copy-paste.
<<~RUBY errors = Ask::SolidErrors.recent(limit: 10) errors.map { |e| { id: e.id, class: e.exception_class, message: e.message.truncate(200) } } # Or get full details: error = Ask::SolidErrors.find(id) error.backtrace error.context # Or work with occurrences: error = Ask::SolidErrors.find(id) error.occurrences.each do |occ| puts occ.parsed_backtrace end RUBY
- VERSION =
"0.1.0"
Class Method Summary collapse
-
.by_class(klass) ⇒ ActiveRecord::Relation<SolidErrors::Error>
Convenience — filter errors by exception class name.
-
.by_severity(severity) ⇒ ActiveRecord::Relation<SolidErrors::Error>
Convenience — filter errors by severity level.
-
.client ⇒ ClientProxy
Returns a client proxy for querying SolidErrors.
-
.ensure_solid_errors_loaded! ⇒ Object
Raise
LoadErrorwith a clear message when thesolid_errorsgem is not available. -
.find(id) ⇒ SolidErrors::Error
Convenience — find a single error by its primary key.
-
.occurrence_count(error) ⇒ Integer
Convenience — return the occurrence count for an error.
-
.recent(limit: 10) ⇒ ActiveRecord::Relation<SolidErrors::Error>
Convenience — return the most recently recorded errors.
-
.resolved ⇒ ActiveRecord::Relation<SolidErrors::Error>
Convenience — return all resolved errors.
-
.search(query) ⇒ ActiveRecord::Relation<SolidErrors::Error>
Convenience — search errors whose message contains the given text.
-
.unresolved ⇒ ActiveRecord::Relation<SolidErrors::Error>
Convenience — return all unresolved errors.
Class Method Details
.by_class(klass) ⇒ ActiveRecord::Relation<SolidErrors::Error>
Convenience — filter errors by exception class name.
59 60 61 |
# File 'lib/ask/solid_errors/client.rb', line 59 def self.by_class(klass) client.where(exception_class: klass) end |
.by_severity(severity) ⇒ ActiveRecord::Relation<SolidErrors::Error>
Convenience — filter errors by severity level.
67 68 69 |
# File 'lib/ask/solid_errors/client.rb', line 67 def self.by_severity(severity) client.where(severity: severity) end |
.client ⇒ ClientProxy
Returns a client proxy for querying SolidErrors.
No authentication is needed — SolidErrors runs in the same database as the Rails app. The proxy delegates to SolidErrors::Error and SolidErrors::Occurrence models, returning ActiveRecord::Relation objects that can be further chained by the agent.
19 20 21 22 |
# File 'lib/ask/solid_errors/client.rb', line 19 def self.client ensure_solid_errors_loaded! ClientProxy.new end |
.ensure_solid_errors_loaded! ⇒ Object
Raise LoadError with a clear message when the solid_errors gem is not available.
137 138 139 140 141 142 |
# File 'lib/ask/solid_errors/client.rb', line 137 def self.ensure_solid_errors_loaded! return if defined?(::SolidErrors) raise ::LoadError, "The `solid_errors` gem is not installed. " \ "Add `gem 'solid_errors'` to your Gemfile and run `bundle install`." end |
.find(id) ⇒ SolidErrors::Error
Convenience — find a single error by its primary key.
37 38 39 |
# File 'lib/ask/solid_errors/client.rb', line 37 def self.find(id) client.find(id) end |
.occurrence_count(error) ⇒ Integer
Convenience — return the occurrence count for an error.
83 84 85 |
# File 'lib/ask/solid_errors/client.rb', line 83 def self.occurrence_count(error) client.occurrence_count(error) end |
.recent(limit: 10) ⇒ ActiveRecord::Relation<SolidErrors::Error>
Convenience — return the most recently recorded errors.
28 29 30 |
# File 'lib/ask/solid_errors/client.rb', line 28 def self.recent(limit: 10) client.recent(limit: limit) end |
.resolved ⇒ ActiveRecord::Relation<SolidErrors::Error>
Convenience — return all resolved errors.
51 52 53 |
# File 'lib/ask/solid_errors/client.rb', line 51 def self.resolved client.resolved end |
.search(query) ⇒ ActiveRecord::Relation<SolidErrors::Error>
Convenience — search errors whose message contains the given text.
75 76 77 |
# File 'lib/ask/solid_errors/client.rb', line 75 def self.search(query) client.where("message LIKE ?", "%#{client.sanitize_sql_like(query)}%") end |
.unresolved ⇒ ActiveRecord::Relation<SolidErrors::Error>
Convenience — return all unresolved errors.
44 45 46 |
# File 'lib/ask/solid_errors/client.rb', line 44 def self.unresolved client.unresolved end |