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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:12:11+00:00 2026-05-16T02:12:11+00:00

I currently have this class that another programmer in my team coded: public static

  • 0

I currently have this class that another programmer in my team coded:

public static class SoapExecuter
{
    private static readonly ILog logger;

    public static Exception ExecuterException { get; private set; }

    public static bool IsSoapException
    {
        get 
        {
            if (ExecuterException == null)
                return false;

            return ExecuterException.GetType() == typeof(SoapException);
        }
    }

    public static bool Execute(Action action)
    {
        ExecuterException = null;
        bool passed = false;

        try
        {
            action();
            passed = true;
        }
        catch (SoapException se)
        {
            ExecuterException = se;
            logger.log(se);
        }
        catch (Exception ex)
        {
            ExecuterException = ex;  
            logger.log(ex);
        }

        return passed;
    }
}

This is not very idiomatic and I would like to change it to something that happens within the try…catch clause.
Is there a way to not violate DRY and still stay within the idioms the language offers?
Of course I can inherit from the SoapException and log it but I’ll have to catch a SoapException and create a new exception object that wraps it and then throw it only to be silenced one level above.
Any idea guys?

  • 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-16T02:12:12+00:00Added an answer on May 16, 2026 at 2:12 am

    Sounds like what you really want is not to handle that exception inside Execute at all. The responsibility for handling the exception seems to lie with the code that calls Execute.

    Of course you can still catch it, store it in ExecuterException, log it, and then rethrow it using throw; — but the purpose of ExecuterException eludes me. It seems that you only need it for IsSoapException, which in turn is much better written as ExecuterException is SoapException anyway, which even takes care of nullness and subclasses.

    I don’t think anyone can be of any further help than this without seeing the code that uses the code you posted. If that code queries ExecuterException only immediately after calling Execute, then you can (and should) probably just change it to a try/catch in that code. If it actually queries ExecuterException elsewhere, then you could consider having that code store the reference instead, but either way, it would mean that the code is pretty entangled spaghetti code and probably requires a major rewrite anyway.

    (By the way, just to nitpick, the first of the two catch clauses in your code is completely redundant. If you remove it you get exactly the same behaviour — unless logger.log has a special overload for SoapException, but then you should probably restructure that too.)

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

Sidebar

Ask A Question

Stats

  • Questions 513k
  • Answers 513k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer All the links in your page referring to the http://www.shop.dearearth.net/skin/frontend/base/… May 16, 2026 at 5:54 pm
  • Editorial Team
    Editorial Team added an answer For basic validation of Open XML documents, you can use… May 16, 2026 at 5:54 pm
  • Editorial Team
    Editorial Team added an answer You're using a subquery in a context where only scalar… May 16, 2026 at 5:54 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Ok heres the situation. I have a View controller class that serves as the
Currently I have an edittext field that when the user presses enter it does
Hi LaTeX enthusiasts and TeX programmers! I'm currently developing a single-page document class for
I'm currently using an XMLSerializer to serialize a list of a class of my
Sorry, I know that this topic has been covered a bit. I've read the
Consider the following PHP code: <?php require_once(myDBclass.php); class a { private $tablename; private $column;
Let's say that I'm currently designing an application where I will need to use
Our desktop application consists of a Mono/.NET 3.5 back end that communicates via USB
I am in the design phase of a programming language, currently thinking about the
I'm building an hierarchy of objects that wrap primitive types, e.g integers, booleans, floats

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.