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 7787021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:32:08+00:00 2026-06-01T20:32:08+00:00

I have a loop that runs multiple times and is prone to exceptions (it

  • 0

I have a loop that runs multiple times and is prone to exceptions (it is web based). However, I don’t want to throw anything directly from the method as I want it to move on the next iteration in case of an error. So what I did was I added a reference parameter that the caller passes, and all exceptions are put there.

I want to return to the user the Exception as well as the fault URL, so I created the following object:

class KeywordException
{
    Exception ex;
    string faultURL;
}

It is returned to the user as ref List<KeywordException> exceptions

Ok it’s all good so far, and I catch exceptions like so:

catch (ArgumentNullException ane)
{
    exceptions.Add(new KeywordException(ane, URL));
    continue;
}

It works and the exception is returned to the user, but how can I from the calling code know what the exception actually was? All I get is Exception when it is actually an ArgumentNullException in this case.

  • 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-06-01T20:32:10+00:00Added an answer on June 1, 2026 at 8:32 pm

    The problem is that your KeywordException class is storing the exception as an Exception (which makes sense and is probably correct).

    Why do you want to know the exact type of exception? Is it to display a message to the user? In this case you can use reflection to get the concrete type of the ex variable:

    string exceptionType = keywordException.ex.GetType().Name;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Short Question I have a loop that runs 180,000 times. At the end of
I have a for loop that runs 15 times, with dh.setDoors() in every iteration.
I have one Private sub that runs in a loop. I want the sub
I have a loop that runs through a variety of websites and I'd like
I have a loop that runs for approx. 25 minutes i.e 1500 seconds. [100
I have a handler and a runnable, Handler has a loop that runs from
I have written a C# app that runs constantly in a loop and several
So I have a Linux program that runs in a while(true) loop, which waits
I have a thread in Ruby. It runs a loop. When that loop reaches
I have a thread that appends rows to self.output and a loop that runs

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.