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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:07:00+00:00 2026-05-25T16:07:00+00:00

I try to put a exception logic which a part of a system can

  • 0

I try to put a exception logic which a part of a system can fall back to on unexpected behaviors.

The work should be done of a new class that inherits Exception object and extend the functionality with a new “exit” which consist of a error-signal to the user and a logging routine.

I may need to understand the use of throw better, but I though I could make it fairly transparent by i.e. this:

public SomeObject GetVersion(byte p)
{
    switch ((SomeObject)p)
    {
        case Version.SomeType1:
            ...
            break;
        case Version.SomeType2:
            ...
            break;
        default:
            throw new UnexpectedQueryException(this.someOtherObject, errorCode);
    }
    return (SomeObject)p;
}

I think you can see what I’m trying to do here.

I try to throw when the application can’t serve the request. The throw are meant to put the execution through the exception (which generates a adequate error code to caller). This example is a error of type “I know you gived me a 9 but only 1-8 is allowed here)”, which errorCode sends further to the UnexpectedQueryException(...).

Unfortunately the application take the throw as unhandled and closes my Thread and application won’t operate until restart. Beside this scenario i’m also use this throw in catch statements.

In my eyes, this is Very handled.

What best practice here?
I want the exception handling to be a “fall back” to activate on different scenarios (like above) so I always have an easy way to communicate an error back to the user (which mean I can send very exact info about where the exception is).

Also i, Of Course, want the application to continue working.

A part of code from the Exception logic,

public class UnexpectedQueryException: CommunicationException
{
    public UnexpectedQueryException(SomeObject object, ErrorCode errorCode) : base("UnexpectedQueryException", object, errorCode)
    {
     .........
    }
}

Which, in turn, inherits the base Exception object,

public class CommunicationException : Exception
{
    ..some fields..

    public CommunicationException(string Message, SomeObject object, ErrorCode errorcode)
    {
     .....
    }
    public CommunicationException() : base("CommunicationException")
    { }
}
  • 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-25T16:07:01+00:00Added an answer on May 25, 2026 at 4:07 pm

    If you throw an exception in your code, you need to catch it and do something with it – if you don’t, you have not handled it.

    If you throw within a catch block, the same thing applies. You have thrown an exception which will keep propagating till a suitable catch block has been found. If non exists, it is unhandled.

    You need to structure your higher level (UI) code so it catches the right types of exceptions and communicates the information you want back to the user:

    try
    {
      // code that can throw 
    }
    catch(VerySpecificException ex)
    {
      // communicate to user details about VerySpecificException. 
      // possibly log.
      // Do not re-throw or throw a new excpetion as it is now handled. 
    }
    catch(AnotherSpecificException ex)
    {
      // communicate to user details about AnotherSpecificException. 
    }
    catch(LessSpecificException ex)
    {
      // communicate to user details about LessSpecificException. 
    }
    catch(EveLessSpecificException ex)
    {
      // communicate to user details about EvenLessSpecificException. 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I try to put a value into a DATE field which is invalid,
i try to put a lock to a static string object to access to
I’m using C# and WinForms to try and put just the date from a
I am getting raw aac data from web stream and try to put it
I have this code for update: public Boolean update() { try { data.put(ContactsContract.Groups.SHOULD_SYNC, true);
I have a UITableViewCell and it is UITableViewCellStyleDefault . When I try to put
I know it sounds weird but I am required to put a wrapping try
1) To my understanding, in a three-tier Asp.Net application we should implement exception handling
I have a Ria service to call logic code. I want to write try
I put some data access logic in my default construct of ViewModel class. However,

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.