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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:50:16+00:00 2026-05-26T06:50:16+00:00

I see the need to copy and paste the following error handling code several

  • 0

I see the need to copy and paste the following error handling code several times. What are my options when working within a Catch statement?

  • In doing so, will I lose valuable information in the process? (example: are exceptions re-wrapped in another exception, or loss of stack information)

  • How can someone tell the difference between a “throw” in myAbstractClass and one in the Select method below?

Here is sample code I want to replicate

public class StackUserDataSource : AbstractEnhancedTableDataSource<StackUserDataServiceContext>
{
  //.. stuff

 public IEnumerable<StackUserDataModel> Select() 
    {
        try
        {
            var results = from c in _ServiceContext.StackUserTable
                          select c;

            var query = results.AsTableServiceQuery();
            var queryResults = query.Execute();

            return queryResults;
        }
        catch (StorageClientException e)
        {

           // Todo: consider sticking this in another central location    
            switch (e.ErrorCode)
            {
                case StorageErrorCode.AccessDenied:
                    break;
                case StorageErrorCode.AccountNotFound:
                    break;
                case StorageErrorCode.AuthenticationFailure:
                    break;
                // ... Yadda yadda, handle some exceptions, not others.. this is a demo.
                case StorageErrorCode.TransportError:
                    break;
                default:
                    break;
            }
            throw;
        }
    }

Update:

I doubt this is possible, but can I dynamically catch and filter exceptions in an external library? The concept goes like this

        try
        {
            var results = from c in _ServiceContext.StackUserTable
                          select c;

            var query = results.AsTableServiceQuery();
            var queryResults = query.Execute();

            return queryResults;
        }
        catch (MyExternalExceptionHelperDLL e)
        {
            // all exceptions referenced in MyExternalHelper are passed below
            MyExternalExceptionHelper.ProcessException(e);
         }
         catch (exception)
        {
         }

Since it’s probably not possible for the MyExternalExceptionHelperDLL to dynamically pick and choose what to listen for (i.e. SQL, vs Networking vs File, but not authentication)

        try
        {
            var results = from c in _ServiceContext.StackUserTable
                          select c;

            var query = results.AsTableServiceQuery();
            var queryResults = query.Execute();

            return queryResults;
        }
         catch (exception e)
        {
           MyExternalExceptionHelper.ProcessException(e);

           // The problem is that I don't know how to catch exceptions thrown from that static method above,
           // or how to override that exception handling...
        }

But with the above code, its not clear to me how the end user can opt into or override my methods of event handling.

  • 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-26T06:50:17+00:00Added an answer on May 26, 2026 at 6:50 am

    You could do something like this. The important part is that the throw needs to be in the original catch block in order to preserve the stack trace.

    public IEnumerable<StackUserDataModel> Select() 
    {
        try
        {
            ...
        }
        catch (StorageClientException e)
        {
           // You could do this if there is no fancy processing to do
           if (!IsCatchableException(e))
              throw;
        }
    }
    
    bool IsCatchableException(StorageClientException e)
    {
        ... optionally do some fancy processing of the exception, e.g. logging....
        switch (e.ErrorCode)
        {
            case StorageErrorCode.AccessDenied:
            case StorageErrorCode.AccountNotFound:
            ....
            return true;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a biztalk project and I need to copy (filtered) content
I'm using the Infragistics UltraWinGrid to present some data. I need some Excel copy/paste
While developing my ASP.NET MVC, I have started to see the need for a
I need to see the contents of the viewstate of an asp.net page. I
We need to see what methods/fields an object has in Javascript.
I need to see the queries submitted to a PostgreSQL server. Normally I would
I need to see the contents of a std::map variable while debugging. However, if
I am developing a web site and need to see how it will look
I am reverse engineering an app and I need to see what is in
I have a strange (don't ask) need to see a few examples of a

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.