title: How to throw exception without losing information that is received as a parameter from backend
body: <p>My application needs to catch and display the exception that has come from back end in the form of an exception object to front end. I need to propagate that error as a parameter to the other classes and set flags and perform some required cleanup and then finally throw the exception. I dont want to lose any stack trace and other information. I see I cant just use throw e. I cant use just throw either as I have got the exception object as a parameter. Could some one help me to throw the received object the right way?</p>
  
  <pre><code>public void FunctionThatGetsExceptionAsparameter(Exception ex)
      {
          //The backend caught the exception, wrapped it and put in an object and then passed it to this function as a parameter 
          //calls function in other class by passing this object
          FunctionInOtherClass(ex);
      }
  
      public void FunctionInOtherClass(Exception ex)
      {
          if (ex != null)
          {
              //set some flags to perform some other BL because of exception happened in backend
              //send the object to higher layer class
              //calls function in higher layer class by passing this object
              FunctionInHigherLayerClass(ex);
          }
  
      }
  
      public void FunctionInHigherLayerClass(Exception ex)
      {
          //Throw the exception object to be caught by our application exception handler to display the standard exception box
          throw ex;
      }
  </code></pre>