Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7176095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:26:20+00:00 2026-05-28T16:26:20+00:00

I would like to catch an exception an tell if it was me that

  • 0

I would like to catch an exception an tell if it was me that deliberately threw the error or something else like a runtime error (object not instance of an object).

try
{
    throw new Exception("throw this", "these can be many possible values");
}
catch (System.Exception ex)
{
    if (IThrew) // <--- how can i tell if i threw or not?
    {
        exReport = "one thing"; // <--- Should go in here in this example.
    }
    else
    {
        exReport = "another thing";
    }

    throw new FaultException<ExceptionReport>(exReport, new FaultReason(ex.Message), new FaultCode("Receiver"));

}

Clarification:

I need keep record of all the exceptions then at the end display them in an exceptions report (array of exceptions). This is part of a schema I am REQUIRED to follow. (so please don’t ask me to do it another way).

I have it all working great it outputs something like:

...
<soap:Detail>
<ows:ExceptionReport>
 <Exception exceptionCode="…" locator="…">
  <ExceptionText>…</ExceptionText>
 </Exception>
 <Exception exceptionCode="…" locator="…">
  <ExceptionText>…</ExceptionText>
 </Exception>
</ows:ExceptionReport>
</soap:Detail>
...

The problem is that when i’ll have a few errors already in my ExceptionReport, then a runtime error will occur.

But i’ve realized i’m going the wrong way about this… as Gary mentioned… i shouldn’t be using exceptions as flow control.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T16:26:21+00:00Added an answer on May 28, 2026 at 4:26 pm

    You can’t tell why an exception was thrown.

    What you can do is create your own exception classes so you can catch them – these will be the exceptions thrown on purpose. That is, since you created the exception class, the framework is not going to throw these.

    try
    {
     // something
    }
    catch(MyCustomException ex)
    {
       // Thrown by Application logic
    }
    catch(System.Exception ex)
    {
       // Could by thrown by anything
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Whenever my application throws an unhandled exception, I would like WinDbg to catch that
I would like to test some exception handling logic in the empty catch block
I'm using Kohana 2. I would like to catch a database exception to prevent
I would like to catch an exception I expect but allow the others through.
I have a method that looks like this: try { doStuff(); } catch (Exception
I have a base class, and I would like to catch all exceptions of
I would like to catch all dev tags and their respective content, through php
I am currently playing around with chrome extensions. I would like to catch google
I have a Try Catch in my code. I would like to know if
Would like a for loop in jquery so that: For every hover_link: show hidden

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.