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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:54:26+00:00 2026-05-10T23:54:26+00:00

I am currently doing a code review and the following code made me jump.

  • 0

I am currently doing a code review and the following code made me jump. I see multiple issues with this code. Do you agree with me? If so, how do I explain to my colleague that this is wrong (stubborn type…)?

  • Catch a generic exception (Exception ex)
  • The use of ‘if (ex is something)’ instead of having another catch block
  • We eat SoapException, HttpException and WebException. But if the Web Service failed, there not much to do.

Code:

try {     // Call to a WebService } catch (Exception ex) {     if (ex is SoapException || ex is HttpException || ex is WebException)     {         // Log Error and eat it.     }     else     {         throw;     } } 
  • 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. 2026-05-10T23:54:27+00:00Added an answer on May 10, 2026 at 11:54 pm

    The mantra is:

    • You should only catch exceptions if you can properly handle them

    Thus:

    • You should not catch general exceptions.

    In your case, yes, you should just catch those exceptions and do something helpful (probably not just eat them–you could throw after you log them).

    Your coder is using throw (not throw ex) which is good.

    This is how you can catch multiple, specific exceptions:

    try {     // Call to a WebService } catch (SoapException ex) {     // Log Error and eat it } catch (HttpException ex) {     // Log Error and eat it } catch (WebException ex) {     // Log Error and eat it } 

    This is pretty much equivalent to what your code does. Your dev probably did it that way to avoid duplicating the ‘log error and eat it’ blocks.

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

Sidebar

Ask A Question

Stats

  • Questions 102k
  • Answers 102k
  • 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 You could make it an internal method, and use InternalsVisibleToAttribute… May 11, 2026 at 8:13 pm
  • Editorial Team
    Editorial Team added an answer You have to have a purpose. You either need the… May 11, 2026 at 8:13 pm
  • Editorial Team
    Editorial Team added an answer Dates / Times are stored in mysql the same way… May 11, 2026 at 8:13 pm

Related Questions

I am currently creating an e-commerce site using C# ASP.NET MVC and have just
I have large batches of XHTML files that are manually updated. During the review
I am currently doing some work for a company that runs a legacy web
A bit of background first: I am using base code from a remote SVN

Trending Tags

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

Top Members

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.