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

  • Home
  • SEARCH
  • 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 833987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:36:24+00:00 2026-05-15T04:36:24+00:00

What is the difference between try { … } catch{ throw } and try{

  • 0

What is the difference between

try { ... }
catch{ throw }

and

try{ ... }
catch(Exception e) {throw new Exception(e.message) }

regardless that the second shows a message.

  • 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-15T04:36:24+00:00Added an answer on May 15, 2026 at 4:36 am

    throw; rethrows the original exception and preserves its original stack trace.

    throw ex; throws the original exception but resets the stack trace, destroying all stack trace information until your catch block.

    NEVER write throw ex;

    throw new Exception(ex.Message); is even worse. It creates a brand new Exception instance, losing the original stack trace of the exception, as well as its type. (eg, IOException).
    In addition, some exceptions hold additional information (eg, ArgumentException.ParamName).
    throw new Exception(ex.Message); will destroy this information too.

    In certain cases, you may want to wrap all exceptions in a custom exception object, so that you can provide additional information about what the code was doing when the exception was thrown.

    To do this, define a new class that inherits Exception, add all four exception constructors, and optionally an additional constructor that takes an InnerException as well as additional information, and throw your new exception class, passing ex as the InnerException parameter. By passing the original InnerException, you preserve all of the original exception’s properties, including the stack trace.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What is the difference between try { } catch { throw; } and try
what's the difference between using try catch surrounding a function block that is called
What is the difference between try { ... } catch (NHibernate.ADOException exception) {} and
Possible Duplicate: Difference between try-catch syntax for function What is the difference in the
Possible Duplicate: Difference between try-catch syntax for function Few days ago I was reading
Possible Duplicate: When is a function try block useful? Difference between try-catch syntax for
Syntax aside, what is the difference between try { } catch() { } finally
Is there any functional difference in Python between a try statement and an if
What is the difference between ',' and 'as' in except statements, eg: try: pass
The difference between Chr and Char when used in converting types is that one

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.