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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:09:01+00:00 2026-05-22T17:09:01+00:00

A method performs several tasks: public void method () { try { task1(); //may

  • 0

A method performs several tasks:

public void method () {

    try {
         task1(); //may throw sql exception
         task2(); //may throw sql exception
         task3(); //may throw sql exception
   } catch (SQLException se) {
       //from which line cames the exception?
   }

I’m looking for a criteria to adopt in these situations.
Currently my idea is this:
1) if i need to take some action depending on the specific line that has thrown the exception, the only thing is surrond each statement with his-own try-catch; three in the example.
2) if i not need to take a specific action based on the line that throws the exception, then the stack trace will give enough information to know line has gone wrong without a try-catch block for each instruction, that makes the code less readable.

  • 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-22T17:09:02+00:00Added an answer on May 22, 2026 at 5:09 pm

    The stacktrace will contain all the necessary information.

    If you need to take specific actions, then in each taskX() method you may want to throw a different exception, wrapping SQLException. Same verbosity though.

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

Sidebar

Related Questions

I have a method in a class that performs several tasks (calling other methods,
I have an onclick function which performs several tasks. In another JavaScript function I
I am working on an MVVM app that performs several tasks in the background,
I have a .NET class library containing a class with a method that performs
So, I have a method that performs a parametrised LIKE query. The method takes
I've got a method that takes in an HttpRequest object and performs differently based
I’m trying to figure out whether FormsAuthentication.RedirectFromLoginPage (called inside method M() ), performs redirection
If I have a method called -uploadToServer:(Object *)objectToUpload, and a mutable array of several
I have several properties with getter and setter method in one action class. Those
What is best practice and, most importantly, the method that performs best? I have

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.