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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:07:38+00:00 2026-06-07T16:07:38+00:00

When I try using a try/catch I am confused as to what type of

  • 0

When I try using a try/catch I am confused as to what type of errors to try and catch.
In doing research here in stackoverflow I have seen the comments on not recommending the use of

catch(Exception e)

as it is to generic but where can I find what type of specific errors I should look for an example would be trying to play an audio file using pseudo code

try{
  play audio file
}
catch ( invalid file)
catch ( bad connection)
catch ( file not found)
catch ( invalid file size)
etc

The pseudo errors I list above cover a broad range of functionality from internet connectivity to file specific information.

How do I cover all of these cases

I have an App that shows a message that says the file cannot be played but I would like to catch the specific error and see what is happening each time this message could appear and fix it.

What if I wanted to try and catch an error for something that is unique that I code myself.

This may be a bad example but if I want to calculate the duration of a planets orbit and generate an error if the duration is smaller than some value. The values used should cause an area to be over 13 months but for some UNKNOWN reason something causes it to be below 13 and I want to find out why so I use a try catch because something is wrong and I do not know what it is, maybe I need to use a absolute value of a number instead of the number itself or something similar the main point was I do not know what the error was caused by.

  • 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-06-07T16:07:40+00:00Added an answer on June 7, 2026 at 4:07 pm

    You can catch specific errors by specifying a particular type to catch:

    try {
        ...file open...
    } catch (IOException e) {
        ...handle IO exception...
    }
    

    There’s a giant list of exceptions, all subclasses of Exception. The exceptions are organized in a hierarchy, so some subsume others. For instance, EOFException is a subclass of IOException, so if you want to catch any IO error (including EOF errors) use IOException, if you only want to catch EOF in particular, use EOFException.

    You can write your own sublcass of Exception (or one of its subclasses), and catch it like any other predefined exception.

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

Sidebar

Related Questions

How can I avoid NullPointerExceptions ? I have tried using try-catch blocks but that
I've been developing big applications using try/catch to handle all the exceptions and errors;
Why using try catch is bad for application performance? I'm not saying about using
Out of habit I've been using try/catch blocks in my application code for all
I am writing a stored procedure where i m using try catch block. Now
I am currently using two catch blocks after a try block. The first catches
I'm trying to throw an exception (without using a try catch block) and my
Anyone knows why my sql query doesn't work after using a try catch function?
I was just wondering which would be cheaper, using a try catch block for
I've been told that there is some overhead in using the Java try-catch mechanism.

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.