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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:51:26+00:00 2026-05-25T10:51:26+00:00

I have a webservice that returns xml.The problem is methods that are executed deep

  • 0

I have a webservice that returns xml.The problem is methods that are executed “deep” in code where a simple return won’t stop program execution.

What happens is I set my xml error message in a catch statement but the code will keep executing through the rest of the outer method and overwrite my xml error response.

Is there a design pattern or best practice to get around this?

      Main Program Block                    SomeClass

         execute someMethod()     ---->     public someMethod()
                                            {
                                                    -----> private method()// try / catch error occurred (send back an xml error response)

                                                    // code execution continues and does some stuff and generates an xml response
                                                    <request>
                                                    <success>true</success>
                                                    </request>
                                            }
  • 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-25T10:51:27+00:00Added an answer on May 25, 2026 at 10:51 am

    You can re-throw the exception. For example:

        private static string errorMessage;
        static void Main(string[] args)
        {
            try
            {
                Test1();
            }
            catch (Exception ex) 
            {
                Console.WriteLine("Something went wrong deep in the bowels of this application! " + errorMessage );
            }
    
        }
    
        static void Test1()
        {
            try
            {
                Test2(1);
                Test2(0);   
            }
            catch (Exception ex)
            {
                errorMessage = ex.Message;
                throw;
            }
        }
    
        static string Test2(int x)
        {
            if (x==0) throw new ArgumentException("X is 0!");
            return x.ToString();
        }
    

    An additional piece of advice: When re-throwing an exception, use throw;, not throw ex;, in order to preserve the stack trace. See this for some more information on the subject.

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

Sidebar

Related Questions

I have a WebService that returns XML in a SOAP response: <?xml version=1.0 encoding=utf-8
I have a RPC encoded PHP webservice that returns a simple soap envelope with
I have a simple WebService method that returns database results as a DataSet. This
I have an ASMX webservice with a number of methods which will return XML.
I have a PHP webservice that returns an XML output, and one of the
I have a third party web service that returns this xml <book> <release_date>0000-00-00</release_date> </book>
We have HTTP webservices that are RPC. They return XML representing the object the
I have a webservice that returns a list of Clinics near a certain lat/long.
I have an ASP.NET WebService that returns an object of List public class Students
I have a webservice method that reads a photo and returns its byte data.

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.