displaying exception message from custom exception

Discussion in 'ASP .Net' started by bdgreen@pacbell.net, Aug 18, 2006.

  1. Guest

    Hi,

    I made a custom exception, derived from ApplicationException. If the
    exception is thrown, the erroring web page shows the line of code where
    I throw exception, and doesn't display the exception message. Do I
    need to catch my custom exception, and rethrow it as another type of
    exception to make the message display?

    I still want to page to error out, I don't want to catch it and return
    a user-friendly message or anything. The page needs to error so that
    operations will know errors are being thrown.

    Thanks
    , Aug 18, 2006
    #1
    1. Advertising

  2. Groove Guest

    I asked the same question at 11:24 am and no response yet. Where is
    everyone?

    --



    <> wrote in message
    news:...
    > Hi,
    >
    > I made a custom exception, derived from ApplicationException. If the
    > exception is thrown, the erroring web page shows the line of code where
    > I throw exception, and doesn't display the exception message. Do I
    > need to catch my custom exception, and rethrow it as another type of
    > exception to make the message display?
    >
    > I still want to page to error out, I don't want to catch it and return
    > a user-friendly message or anything. The page needs to error so that
    > operations will know errors are being thrown.
    >
    > Thanks
    >
    Groove, Aug 18, 2006
    #2
    1. Advertising

  3. sloan Guest

    see
    http://www.aspnetresources.com/blog/custom_exception_class.aspx



    What I do is this.. which isn't what you want.

    try

    {

    // web page stuff

    }

    catch(Exception ex)
    {
    Response.Write (ex.Message);
    // or this
    /*
    if(null!=ex.InnerExeption)
    {
    Response.Write(ex.InnerException.Message);
    }
    */
    }


    Ok.. having said that.. then yeah. do this.

    try
    {
    //web stuff
    }

    catch(MyNamespace.MyException mex)
    {
    throw new SuperFriendlyException("MyException was thrown, but I don't
    want to show you its info");
    }
    catch(Exception ex)
    {
    throw new SuperFriendlyException("ex was thrown, but I don't want to
    show you its info");
    }

    Something like that.

    Note, MyException is not the same object as SuperFriendlyException



    <> wrote in message
    news:...
    > Hi,
    >
    > I made a custom exception, derived from ApplicationException. If the
    > exception is thrown, the erroring web page shows the line of code where
    > I throw exception, and doesn't display the exception message. Do I
    > need to catch my custom exception, and rethrow it as another type of
    > exception to make the message display?
    >
    > I still want to page to error out, I don't want to catch it and return
    > a user-friendly message or anything. The page needs to error so that
    > operations will know errors are being thrown.
    >
    > Thanks
    >
    sloan, Aug 18, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sanjay Kedare

    Displaying server side message box

    Sanjay Kedare, Aug 22, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    2,424
    Sanjay Kedare
    Aug 22, 2003
  2. Paul Johnson

    Displaying Message Boxes

    Paul Johnson, Jan 1, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    2,242
    Steve C. Orr [MVP, MCSD]
    Jan 2, 2004
  3. Cris Rock
    Replies:
    4
    Views:
    491
    Cris Rock
    Feb 12, 2004
  4. darrel
    Replies:
    5
    Views:
    346
    Andrew Jones
    Jul 2, 2004
  5. Helen
    Replies:
    5
    Views:
    1,010
    Helen
    Sep 9, 2004
Loading...

Share This Page