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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T07:48:48+00:00 2026-05-12T07:48:48+00:00

Here’s a question where my real world programming inexperience shines through. I have a

  • 0

Here’s a question where my real world programming inexperience shines through. I have a function which makes a call to three other functions:

Public Sub StartService()
    RunSearch()
    SaveMessages()
    DeleteMessages()
End Sub

within each of the methods RunSearch(), SaveMessages() and DeleteMessages() I am using Try Catch statements to catch errors. Right now I catch the error and write to an error log when RunSearch() errors out, but I’m also get two errors from SaveMessages() and DeleteMessages() because these functions are dependent upon RunSearch() not returning an error. I am trying to build good a error catching foundation so I don’t just want to kill the app when there’s an error. My question is this: How can I gracefully stop execution if an error occurs in RunSearch().

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

    Why does RunSearch not rethrow the exception after logging the problem?

    If you don’t want to call SaveMessages() if RunSearch() fails then don’t code it that way.

    My general thought is that each method’s interface is specifying a “protocol”. It must state its behaviour in the event of problems. Approaches include:

    1. If I get an error I will terminate the process. This is pretty extreme, limits the reusability of your method.
    2. I will return a count or status code or somesuch. It’s up to you to decide whether to check that and whether any particular status code means it’s safe to call some other method. I prefer not to rely on the client to remember to check status codes.
    3. If I fail I will leave things so that subsequent processing will be sane. For example, if my job is to create a linked list then in the event of errors I will not leave a dangling pointer or an initialized list. You may get an empty list, but at least well formed subsequent processing will work. This tends to imply some degree of agreement (ie. coupling) with the other methods. This is often the nicest approach, especially when coupled with good logging of the problems.
    4. I will throw an exception if I couldn’t do the work. The exception will indicate whether there’s some chance of things working later if you call be again (I use TransientException and InvalidRequestException quite a lot). Exceptions are useful because the client cannot (for Java checked exceptions) accidentally ignore them. When dealing with problems such as “could not open database” this seems reasonable. We really do not want folks mistaking “couldn’t even get to the database” with “this person has no criminal record”.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's a problem I ran into recently. I have attributes strings of the form
Here is the issue I am having: I have a large query that needs
Here's my scenario - I have an SSIS job that depends on another prior
Here is my code, which takes two version identifiers in the form 1, 5,
Here we go again, the old argument still arises... Would we better have a
Here, i have coded to get data from DB. I want to store the
here's what I currently have, unfortunately I cannot seem to figure out how to
Here's the issue... if I use, say a directory catalog in MEF and have
Here's a basic regex technique that I've never managed to remember. Let's say I'm
Here is a simplification of my database: Table: Property Fields: ID, Address Table: Quote

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.