Correct way to manually send an exception?

aussiegeek's Avatar


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

        # Your Code
      rescue Exception => e
        raise(e) # if you want to re-raise it

    Does that work for you ?


  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?

    error do

    //log to GetExceptonal


    It seems the guys here are working on this, isn't it?

  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


? 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