{"id":13514403,"url":"https://github.com/fractaledmind/solid_errors","last_synced_at":"2025-05-14T20:04:39.769Z","repository":{"id":217195613,"uuid":"743287495","full_name":"fractaledmind/solid_errors","owner":"fractaledmind","description":"database-backed, app-internal exception tracker for Rails applications","archived":false,"fork":false,"pushed_at":"2024-11-01T23:58:03.000Z","size":6026,"stargazers_count":355,"open_issues_count":14,"forks_count":19,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-04-05T10:06:26.135Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fractaledmind.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-14T21:57:10.000Z","updated_at":"2025-04-04T19:51:58.000Z","dependencies_parsed_at":"2024-01-31T16:57:45.610Z","dependency_job_id":"25cb3c3e-38c1-4a72-ae24-39ea18af6aeb","html_url":"https://github.com/fractaledmind/solid_errors","commit_stats":null,"previous_names":["fractaledmind/solid_errors"],"tags_count":32,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fractaledmind%2Fsolid_errors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fractaledmind%2Fsolid_errors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fractaledmind%2Fsolid_errors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fractaledmind%2Fsolid_errors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fractaledmind","download_url":"https://codeload.github.com/fractaledmind/solid_errors/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248568580,"owners_count":21126052,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T05:00:55.460Z","updated_at":"2025-04-12T12:41:29.474Z","avatar_url":"https://github.com/fractaledmind.png","language":"HTML","funding_links":["https://github.com/sponsors/fractaledmind"],"categories":["HTML"],"sub_categories":[],"readme":"# Solid Errors\n\n\u003cp\u003e\n  \u003ca href=\"https://rubygems.org/gems/solid_errors\"\u003e\n    \u003cimg alt=\"GEM Version\" src=\"https://img.shields.io/gem/v/solid_errors?color=168AFE\u0026include_prereleases\u0026logo=ruby\u0026logoColor=FE1616\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://rubygems.org/gems/solid_errors\"\u003e\n    \u003cimg alt=\"GEM Downloads\" src=\"https://img.shields.io/gem/dt/solid_errors?color=168AFE\u0026logo=ruby\u0026logoColor=FE1616\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/testdouble/standard\"\u003e\n    \u003cimg alt=\"Ruby Style\" src=\"https://img.shields.io/badge/style-standard-168AFE?logo=ruby\u0026logoColor=FE1616\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/fractaledmind/solid_errors/actions/workflows/main.yml\"\u003e\n    \u003cimg alt=\"Tests\" src=\"https://github.com/fractaledmind/solid_errors/actions/workflows/main.yml/badge.svg\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/sponsors/fractaledmind\"\u003e\n    \u003cimg alt=\"Sponsors\" src=\"https://img.shields.io/github/sponsors/fractaledmind?color=eb4aaa\u0026logo=GitHub%20Sponsors\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://ruby.social/@fractaledmind\"\u003e\n    \u003cimg alt=\"Ruby.Social Follow\" src=\"https://img.shields.io/mastodon/follow/109291299520066427?domain=https%3A%2F%2Fruby.social\u0026label=%40fractaledmind\u0026style=social\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://twitter.com/fractaledmind\"\u003e\n    \u003cimg alt=\"Twitter Follow\" src=\"https://img.shields.io/twitter/url?label=%40fractaledmind\u0026style=social\u0026url=https%3A%2F%2Ftwitter.com%2Ffractaledmind\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\nSolid Errors is a DB-based, app-internal exception tracker for Rails applications, designed with simplicity and performance in mind. It uses the new [Rails error reporting API](https://guides.rubyonrails.org/error_reporting.html) to store uncaught exceptions in the database, and provides a simple UI for viewing and managing exceptions.\n\n\u003e [!WARNING]\n\u003e The current point release of Rails (7.1.3.2) has a bug which severely limits the utility of Solid Errors. Exceptions raised during a web request *are not* reported to Rails' error reporter. There is a fix in the `main` branch, but it has not been released in a new point release. As such, Solid Errors is **not** production-ready unless you are running Rails from the `main` branch or until a new point version is released and you upgrade.\n\u003e The original bug report can be found [here](https://github.com/rails/rails/issues/51002) and the pull request making the fix is [here](https://github.com/rails/rails/pull/51050). I will try to backport the fix into the gem directly, but I haven't quite figured it out yet.\n\n\n## Installation\n\nInstall the gem and add to the application's Gemfile by executing:\n```bash\n$ bundle add solid_errors\n```\n\nIf bundler is not being used to manage dependencies, install the gem by executing:\n```bash\n$ gem install solid_errors\n```\n\nAfter installing the gem, run the installer:\n```bash\n$ rails generate solid_errors:install\n```\n\nThis will create the `db/errors_schema.rb` file.\n\nYou will then have to add the configuration for the errors database in `config/database.yml`. If you're using sqlite, it'll look something like this:\n\n```yaml\nproduction:\n  primary:\n    \u003c\u003c: *default\n    database: storage/production.sqlite3\n  errors:\n    \u003c\u003c: *default\n    database: storage/production_errors.sqlite3\n    migrations_paths: db/errors_migrate\n```\n\n...or if you're using MySQL/PostgreSQL/Trilogy:\n\n```yaml\nproduction:\n  primary: \u0026primary_production\n    \u003c\u003c: *default\n    database: app_production\n    username: app\n    password: \u003c%= ENV[\"APP_DATABASE_PASSWORD\"] %\u003e\n  errors:\n    \u003c\u003c: *primary_production\n    database: app_production_errors\n    migrations_paths: db/errors_migrate\n```\n\n\u003e [!NOTE]\n\u003e Calling `bin/rails solid_errors:install` will automatically add `config.solid_errors.connects_to = { database: { writing: :errors } }` to `config/environments/production.rb`, so no additional configuration is needed there (although you must make sure that you use the `errors` name in `database.yml` for this to match!). But if you want to use Solid Errors in a different environment (like staging or even development), you'll have to manually add that `config.solid_errors.connects_to` line to the respective environment file. And, as always, make sure that the name you're using for the database in `config/database.yml` matches the name you use in `config.solid_errors.connects_to`.\n\nThen run `db:prepare` in production to ensure the database is created and the schema is loaded.\n\nThen mount the engine in your `config/routes.rb` file:\n```ruby\nauthenticate :user, -\u003e (user) { user.admin? } do\n  mount SolidErrors::Engine, at: \"/solid_errors\"\nend\n```\n\n\u003e [!NOTE]\n\u003e Be sure to [secure the dashboard](#authentication) in production.\n\n## Usage\n\nAll exceptions are recorded automatically. No additional code required.\n\nPlease consult the [official guides](https://guides.rubyonrails.org/error_reporting.html) for an introduction to the error reporting API.\n\nThere are intentionally few features; you can view and resolve errors. That’s it. The goal is to provide a simple, lightweight, and performant solution for tracking exceptions in your Rails application. If you need more features, you should probably use a 3rd party service like [Honeybadger](https://www.honeybadger.io/), whose MIT-licensed [Ruby agent gem](https://github.com/honeybadger-io/honeybadger-ruby) provided a couple of critical pieces of code for this project.\n\n### Manually reporting an Error\n\nErrors can be added to Solid Errors via the [Rails error reporter](https://guides.rubyonrails.org/error_reporting.html).\n\nThere are [three ways](https://guides.rubyonrails.org/error_reporting.html#using-the-error-reporter) you can use the error reporter:\n\n`Rails.error.handle` will report any error raised within the block. It will then swallow the error, and the rest of your code outside the block will continue as normal.\n\n```ruby\nresult = Rails.error.handle do\n  1 + '1' # raises TypeError\nend\nresult # =\u003e nil\n1 + 1 # This will be executed\n```\n\n`Rails.error.record` will report errors to all registered subscribers and then re-raise the error, meaning that the rest of your code won't execute.\n\n```ruby\nRails.error.record do\n  1 + '1' # raises TypeError\nend\n1 + 1 # This won't be executed\n```\n\nYou can also manually report errors by calling `Rails.error.report`:\n\n```ruby\nbegin\n  # code\nrescue StandardError =\u003e e\n  Rails.error.report(e)\nend\n```\n\nAll 3 reporting APIs (`#handle`, `#record`, and `#report`) support the following options, which are then passed along to all registered subscribers:\n\n* `handled`: a Boolean to indicate if the error was handled. This is set to `true` by default. `#record` sets this to `false`.\n* `severity`: a Symbol describing the severity of the error. Expected values are: `:error`, `:warning`, and `:info`. `#handle` sets this to `:warning`, while `#record` sets it to `:error`.\n* `context`: a Hash to provide more context about the error, like request or user details\n* `source`: a String about the source of the error. The default source is `\"application\"`. Errors reported by internal libraries may set other sources; the Redis cache library may use \"redis_cache_store.active_support\", for instance. Your subscriber can use the source to ignore errors you aren't interested in.\n\n```ruby\nRails.error.handle(context: { user_id: user.id }, severity: :info) do\n  # ...\nend\n```\n\n### Configuration\n\nYou can configure Solid Errors via the Rails configuration object, under the `solid_errors` key. Currently, 6 configuration options are available:\n\n* `connects_to` - The database configuration to use for the Solid Errors database. See [Database Configuration](#database-configuration) for more information.\n* `username` - The username to use for HTTP authentication. See [Authentication](#authentication) for more information.\n* `password` - The password to use for HTTP authentication. See [Authentication](#authentication) for more information.\n* `sends_email` - Whether or not to send emails when an error occurs. See [Email notifications](#email-notifications) for more information.\n* `email_from` - The email address to send a notification from. See [Email notifications](#email-notifications) for more information.\n* `email_to` - The email address(es) to send a notification to. See [Email notifications](#email-notifications) for more information.\n* `email_subject_prefix` - Prefix added to the subject line for email notifications. See [Email notifications](#email-notifications) for more information.\n\n### Database Configuration\n\n`config.solid_errors.connects_to` takes a custom database configuration hash that will be used in the abstract `SolidErrors::Record` Active Record model. This is required to use a different database than the main app ([but the primary database can also be used](#single-database-configuration)). For example:\n\n```ruby\n# Use a single separate DB for Solid Errors\nconfig.solid_errors.connects_to = { database: { writing: :solid_errors, reading: :solid_errors } }\n```\n\nor\n\n```ruby\n# Use a separate primary/replica pair for Solid Errors\nconfig.solid_errors.connects_to = { database: { writing: :solid_errors_primary, reading: :solid_errors_replica } }\n```\n\n#### Single Database Configuration\n\nRunning Solid Errors in a separate database is recommended, but it's also possible to use one single database for both the app and the errors. Just follow these steps to add errors to the primary database:\n\n1. Copy the contents of `db/errors_schema.rb` into a normal migration and delete `db/errors_schema.rb`\n2. Remove `config.solid_errors.connects_to` from your configuration files.\n3. Migrate your database.\n\nYou won't have multiple databases, so `database.yml` doesn't need to have the errors database configuration.\n\n#### Authentication\n\nSolid Errors does not restrict access out of the box. You must secure the dashboard yourself. However, it does provide basic HTTP authentication that can be used with basic authentication or Devise. All you need to do is setup a username and password.\n\nThere are two ways to setup a username and password. First, you can use the `SOLIDERRORS_USERNAME` and `SOLIDERRORS_PASSWORD` environment variables:\n\n```ruby\nENV[\"SOLIDERRORS_USERNAME\"] = \"frodo\"\nENV[\"SOLIDERRORS_PASSWORD\"] = \"ikeptmysecrets\"\n```\n\nSecond, you can set the `SolidErrors.username` and `SolidErrors.password` variables in an initializer:\n\n```ruby\n# Set authentication credentials for Solid Errors\nconfig.solid_errors.username = Rails.application.credentials.solid_errors.username\nconfig.solid_errors.password = Rails.application.credentials.solid_errors.password\n```\n\nEither way, if you have set a username and password, Solid Errors will use basic HTTP authentication. If you have not set a username and password, Solid Errors will not require any authentication to view the dashboard.\n\nIf you use Devise for authentication in your app, you can also restrict access to the dashboard by using their `authenticate` constraint in your routes file:\n\n```ruby\nauthenticate :user, -\u003e (user) { user.admin? } do\n  mount SolidErrors::Engine, at: \"/solid_errors\"\nend\n```\n\n#### Email notifications\n\nSolid Errors _can_ send email notifications whenever an error occurs, if your application has ActionMailer already properly setup to send emails. However, in order to activate this feature you must define the email address(es) to send the notifications to. Optionally, you can also define the email address to send the notifications from (useful if your email provider only allows emails to be sent from a predefined list of addresses) or simply turn off this feature altogether. You can also define a subject prefix for the email notifications to quickly identify the source of the error.\n\nThere are two ways to configure email notifications. First, you can use environment variables:\n\n```ruby\nENV[\"SOLIDERRORS_SEND_EMAILS\"] = true # defaults to false\nENV[\"SOLIDERRORS_EMAIL_FROM\"] = \"errors@myapp.com\" # defaults to \"solid_errors@noreply.com\"\nENV[\"SOLIDERRORS_EMAIL_TO\"] = \"devs@myapp.com\" # no default, must be set\nENV[\"SOLIDERRORS_EMAIL_SUBJECT_PREFIX\"] = \"[Application name][Environment]\" # no default, optional\n```\n\nSecond, you can set the values via the configuration object:\n\n```ruby\n# Set authentication credentials and optional subject prefix for Solid Errors\nconfig.solid_errors.send_emails = true\nconfig.solid_errors.email_from = \"errors@myapp.com\"\nconfig.solid_errors.email_to = \"devs@myapp.com\"\nconfig.solid_errors.email_subject_prefix = \"[#{Rails.application.name}][#{Rails.env}]\"\n```\n\nIf you have set `send_emails` to `true` and have set an `email_to` address, Solid Errors will send an email notification whenever an error occurs. If you have not set `send_emails` to `true` or have not set an `email_to` address, Solid Errors will not send any email notifications.\n\n### Examples\n\nThere are only two screens in the dashboard.\n\n* the index view of all unresolved errors:\n\n![image description](images/index-screenshot.png)\n\n* and the show view of a particular error:\n\n![image description](images/show-screenshot.png)\n\n### Usage with API-only Applications\n\nIf your Rails application is an API-only application (generated with the `rails new --api` command), you will need to add the following middleware to your `config/application.rb` file in order to use the dashboard UI provided by Solid Errors:\n\n```ruby\n# /config/application.rb\nconfig.middleware.use ActionDispatch::Cookies\nconfig.middleware.use ActionDispatch::Session::CookieStore\nconfig.middleware.use ActionDispatch::Flash\n```\n\n### Overwriting the views\n\nYou can find the views in [`app/views`](https://github.com/fractaledmind/solid_errors/tree/main/app/views).\n\n```bash\napp/views/\n├── layouts\n│   └── solid_errors\n│       ├── _style.html\n│       └── application.html.erb\n└── solid_errors\n    ├── error_mailer\n    │   ├── error_occurred.html.erb\n    │   └── error_occurred.text.erb\n    ├── errors\n    │   ├── _actions.html.erb\n    │   ├── _error.html.erb\n    │   ├── _row.html.erb\n    │   ├── index.html.erb\n    │   └── show.html.erb\n    └── occurrences\n        ├── _collection.html.erb\n        └── _occurrence.html.erb\n```\n\nYou can always take control of the views by creating your own views and/or partials at these paths in your application. For example, if you wanted to overwrite the application layout, you could create a file at `app/views/layouts/solid_errors/application.html.erb`. If you wanted to remove the footer and the automatically disappearing flash messages, as one concrete example, you could define that file as:\n\n```erb\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003ctitle\u003eSolid Errors\u003c/title\u003e\n    \u003c%= csrf_meta_tags %\u003e\n    \u003c%= csp_meta_tag %\u003e\n\n    \u003c%= render \"layouts/solid_errors/style\" %\u003e\n  \u003c/head\u003e\n  \u003cbody class=\"pb-4\"\u003e\n    \u003cmain class=\"container mx-auto mt-4\"\u003e\n      \u003c%= content_for?(:content) ? yield(:content) : yield %\u003e\n    \u003c/main\u003e\n\n    \u003cdiv class=\"fixed top-0 left-0 right-0 text-center py-2\"\u003e\n      \u003c% if notice.present? %\u003e\n        \u003cp class=\"py-2 px-3 bg-green-50 text-green-500 font-medium rounded-lg inline-block\"\u003e\n          \u003c%= notice %\u003e\n        \u003c/p\u003e\n      \u003c% end %\u003e\n\n      \u003c% if alert.present? %\u003e\n        \u003cp class=\"py-2 px-3 bg-red-50 text-red-500 font-medium rounded-lg inline-block\"\u003e\n          \u003c%= alert %\u003e\n        \u003c/p\u003e\n      \u003c% end %\u003e\n    \u003c/div\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n## Sponsors\n\n\u003cp align=\"center\"\u003e\n  \u003cem\u003eProudly sponsored by\u003c/em\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://www.honeybadger.io?utm_source=fractaledmind\u0026utm_medium=open-source\u0026utm_campaign=solid_errors\"\u003e\n    \u003cimg src=\"https://honeybadger-static.s3.amazonaws.com/brand_assets/honeybadger_logo/honeybadger_logo.svg\" width=\"575\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/fractaledmind/solid_errors. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/fractaledmind/solid_errors/blob/main/CODE_OF_CONDUCT.md).\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the SolidErrors project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/fractaledmind/solid_errors/blob/main/CODE_OF_CONDUCT.md).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffractaledmind%2Fsolid_errors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffractaledmind%2Fsolid_errors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffractaledmind%2Fsolid_errors/lists"}