Skip to content

Commit

Permalink
Ignore Hanami errors by default
Browse files Browse the repository at this point in the history
Configure the loader to ignore some Hanami built-in errors by default so
they don't confuse our users.
  • Loading branch information
tombruijn committed Nov 11, 2024
1 parent ca22ed5 commit f150098
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
13 changes: 13 additions & 0 deletions .changesets/ignore-hanami-errors-by-default.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
bump: patch
type: change
---

Ignore these Hanami errors by default:

- Hanami::Router::NotAllowedError (for example: sending a GET request to POST endpoint)
- Hanami::Router::NotFoundError

They are usually errors you don't want to be notified about, so we ignore them by default now.

Customize the `ignore_errors` config option to continue receiving these errors.
6 changes: 5 additions & 1 deletion lib/appsignal/loaders/hanami.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ def on_load
hanami_app_config = ::Hanami.app.config
register_config_defaults(
:root_path => hanami_app_config.root.to_s,
:env => hanami_app_config.env
:env => hanami_app_config.env,
:ignore_errors => [
"Hanami::Router::NotAllowedError",
"Hanami::Router::NotFoundError"
]
)
end

Expand Down
7 changes: 6 additions & 1 deletion spec/lib/appsignal/loaders/hanami_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
:name => :hanami,
:root_path => Dir.pwd,
:env => :test,
:options => {}
:options => {
:ignore_errors => [
"Hanami::Router::NotAllowedError",
"Hanami::Router::NotFoundError"
]
}
)
end
end
Expand Down

0 comments on commit f150098

Please sign in to comment.