Sija/raven.cr

Kemal Example

crisward opened this issue · 5 comments

Thanks for this module BTW, it looking good so far.

It would be good to see a kemal example. I've required this into my app, but the only exception reported are those I am explicitly sending with raven capture. I'm guessing I need to chuck Raven.capture(exception) into my 500 error handler?

Sija commented

You're right, there's lack of proper docs. atm for what's worth there are API docs you can find at https://sija.github.io/raven.cr/.

Specific example you mentioned is hidden inside of Raven::Kemal::ExceptionHandler documentation.

Sija commented

Does linked example answers your question?

I think so...

I had to do this. Not sure if it should be added to your docs (if I'm doing it correctly)

require "kemal"
require "raven"
require "../lib/raven/src/raven/integrations/kemal.cr"
add_handler Raven::Kemal::ExceptionHandler.new

# example exception
get "/"  do |env|
  1 / 0
end

Kemal.run

Does this look correct ?

Sija commented

Quite correct, tho' I'd simplify it a bit, like:

require "kemal"
require "raven"
require "raven/integrations/kemal"

Raven.configure do |config|
  config.async = true
end

add_handler Raven::Kemal::ExceptionHandler.new

# example exception
get "/" do |env|
  1 / 0
end

Kemal.run
Sija commented

I'm closing this issue, since it looks like you've got the answer to your question.