locked
How can i bubble up an exception to pagebase ? RRS feed

  • Question

  • User1253338400 posted

    Hi 

    I have the foollowing ,

    if (String.IsNullOrWhiteSpace(custID))

      throw new FactoryException("Unable to access current UserID, possible cause is session timeout. Please log out and retry your action.");

    the code then goes to pagebase , but the issue is that when i access   Server.GetLastError() , i cant see the error in the Message . Its seems that the GetLastError is empty ?

    Any reason why this may happen ?

    thanks

    Thursday, August 4, 2016 12:11 AM

Answers

  • User753101303 posted

    Hi,

    Where in PageBase and how do you get there? If you have a catch block it seems expected. AFAIK it expose an exception if it was unhandled (for  example in a Error event rather than really all exceptions that happened). If using catch you'll use catch(FactoryException ex) to handle this particular kind of exception and get its details.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, August 4, 2016 7:41 AM

All replies

  • User753101303 posted

    Hi,

    Where in PageBase and how do you get there? If you have a catch block it seems expected. AFAIK it expose an exception if it was unhandled (for  example in a Error event rather than really all exceptions that happened). If using catch you'll use catch(FactoryException ex) to handle this particular kind of exception and get its details.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, August 4, 2016 7:41 AM
  • User1724605321 posted

    Hi robby ,

    You could also create a custom error page , within the Application_error event , you could log your exception / redirect user to the custom error page by :

      Server.Transfer("~/error.aspx");

    In page_load event of error page , you could get the error by :

      var error = Server.GetLastError();

    Best Regards,

    Nan Yu

    Thursday, August 4, 2016 7:55 AM
  • User1253338400 posted

    Thanks your info helped.

    Thursday, August 4, 2016 11:54 PM