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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T00:28:36+00:00 2026-05-13T00:28:36+00:00

In a stack trace, the method call at the top is the most recently

  • 0

In a stack trace, the method call at the top is the most recently called method.

When the phrase “handle it higher up” is mentioned, does this mean in the method caller or to call another method in the catch block?

Furthermore, in a multi-tier application with an API I wrote, it seems like the best strategy is to always log an exception and handle it as soon as I can and rethrow so the calling method in the UI can display the error. Is there any other usage scenario for exception rethrowing?

Should actions such as retrying an operation or loading another file by default if a file is locked happen in a catch block? Is exception handling about reporting the error or is it about trying the operation again/trying again with different parameters?

Thanks

  • 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-13T00:28:37+00:00Added an answer on May 13, 2026 at 12:28 am
    1. Higher up means lower in the stack, yes.

    2. If you are going to change the way you do the retry — i.e., a strategy that you know WILL work or a collection of strategies from which ONE will work then perhaps you can do it in the catch; however, error codes from functions, or bool’s, are probably better; this is because we are not actually talking about exceptional behaviour.

    3. Exception handling is NOT a looping mechanism, no. Retrying again and again is evil inside exceptions.

    4. Often you should log exceptions, but that is not the main purpose of exceptions. Exceptions are their as a standard mechanism to recover from exceptional behaviour in a well documented (in code) way. They replaced the goto and longjmp statements in C and C++. Where if something did go wrong you would do absolute jumping to a label somewhere in your code.

    5. logging the exception and re-throwing is good, it is accepted convention.


    Example and Discussion

    In your example of locking, you probably should have blocked waiting on the lock to release. Perhaps a spinlock (or waiting for a short, but defined interval) if the lock was not released an exception would be thrown — now in this case, this would be an exception because you wrote the code that locked the file, and you have written your code to release the lock as quickly as possible.

    There is a problem here, you may want to wait a bit longer after your exception has been handled, and i’m betting you want to pretend like the exception never occured — i.e., restart where you left of. but the exception mechanism cannot take you back to the place where the original blocking happened. Your solutions are:

    1. You can start a new code regression from the exception (as you mentioned above) by trying again (not again and again though 😛 ). But this is a new regression of your code, and that is not right.

    2. You can jump to a position where you initially waited. However labels and jumps will make you a pariah in most programming teams. I don’t feel so uneasy about them, but thats me.

    3. You can use error codes and defensive programming. This is the cleanest way to go. Your tries will only embody the code you intended to be run, and your exceptions, the exceptional behaviour which you truly do not expect.

    code:1

    try{...}
    catch{alternateStrategy()}
    

    code:2

    try
    {
       IAmALabel:
       checkFileLock(timeoutVal);
    }
    Catch
    {
       timeoutVal = timeoutVal*2;
       goto IamALabel;
    }
    

    Note: the above is potentially an infinite loop, put an upper limit on it if you use it.

    code 3:

    int tries=3;
    while(true)
    {
       int ret=CheckFileLock(timeoutVal);
       if(ret==0) // 0 = success, anything else represents a distinct error.
          break;
       tries--;
    
       if(tries==0)
          throw exception();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Use the following function like this: Image('/path/to/original.image', '1/1', '150*', './thumb.jpg');… May 13, 2026 at 2:13 am
  • Editorial Team
    Editorial Team added an answer Check you database schema to see if the field (referenced… May 13, 2026 at 2:13 am
  • Editorial Team
    Editorial Team added an answer I figured out the problem - there was a session… May 13, 2026 at 2:13 am

Related Questions

When using reflection it is possible to obtain the call stack (apart from that
I have a problem where a method is getting an undefined variable error, even
When you try to access a key which isn't in a Dictionary (for example),
So I'm making a very basic Twitter app (it's actually Presence 2 from the
I have a semaphore which restricts users to download n number of files at

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.