Correct way to manually send an exception?

aussiegeek's Avatar

aussiegeek

17 Aug, 2010 04:32 AM

I have a block of code which catches an exception and lets the user continue on gracefully.

However, I need to pass this exception on so I can fix investigate if it occurs. Whats the correct way of doing this?

  1. 1 Posted by Wal McConnell on 17 Aug, 2010 09:49 AM

    Wal McConnell's Avatar

    Hi There,

    So there are a couple of options ..

    1. Exceptional.rescue

    You can wrap any code with an Exceptional.rescue block

    Exceptional.rescue do
    # Your Code end

    and any exception thrown in there will be sent to Exceptional.

    You can also pass a string to Exceptional.rescue which will help you identify the error inside Exceptional e.g

    Exceptional.rescue ('CreditCard Validation') do
    # Your Code end

    2. Exceptional::Catcher.handle

    if you want something lower level again, you could just use

    Exceptional::Catcher.handle(exception) directly

      begin
        # Your Code
      rescue Exception => e
        ::Exceptional::Catcher.handle(e)
        raise(e) # if you want to re-raise it
      end

    Does that work for you ?

    cheers,
    Wal

  2. 2 Posted by Tiago Matos on 26 Oct, 2010 03:22 PM

    Tiago Matos's Avatar

    This comment was split into a new discussion: Correct way to manually send an exception?

    Is there any way of logging all the errors in a Sinatra app?
    E.g.:

    error do

    //log to GetExceptonal

    ends

    It seems the guys here are working on this, isn't it?
    http://support.getexceptional.com/discussions/questions/369-404s-wi...

  3. Ciaran Lee closed this discussion on 26 Oct, 2010 05:14 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac