Skip to content

Commit

Permalink
Add better error handling and message for exchange access refuse
Browse files Browse the repository at this point in the history
  • Loading branch information
kickster97 committed Jan 13, 2025
1 parent 1b50ad1 commit 853a545
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/lavinmq/http/handler/error_handler.cr
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ module LavinMQ
Log.info { "method=#{context.request.method} path=#{context.request.path} status=#{context.response.status_code} message=\"#{ex.message}\"" }
rescue ex : IO::Error | ::HTTP::Server::ClientError
Log.info { "method=#{context.request.method} path=#{context.request.path} error=\"#{ex.inspect}\"" }
rescue ex : LavinMQ::Exchange::AccessRefused
Log.error { "method=#{context.request.method} path=#{context.request.path} status=403 error=#{ex.inspect_with_backtrace}" }
context.response.status_code = 403
{error: "access_refused", reason: "Access Refused"}.to_json(context.response)
rescue ex : Exception
Log.error { "method=#{context.request.method} path=#{context.request.path} status=500 error=#{ex.inspect_with_backtrace}" }
context.response.status_code = 500
Expand Down

0 comments on commit 853a545

Please sign in to comment.