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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:45:08+00:00 2026-06-07T05:45:08+00:00

I am dealing with JaudioTagger API to manipulate MP3 files, I have to repeat

  • 0

I am dealing with JaudioTagger API to manipulate MP3 files, I have to repeat the following exceptions over and over again… I was thinking of having a generic exception handler where I could forward each exception maybe with a flag number and the generic method would be deal with it by having different switch cases maybe ? Is it possible ? I would really appreciate if someone could give the method signature or a way to call it

} catch (CannotReadException ex) {
                Logger.getLogger(MainPanel.class.getName()).log(Level.SEVERE, null, ex);
            } catch (ReadOnlyFileException ex) {
                Logger.getLogger(MainPanel.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
                Logger.getLogger(MainPanel.class.getName()).log(Level.SEVERE, null, ex);
            } catch (InvalidAudioFrameException ex) {
                Logger.getLogger(MainPanel.class.getName()).log(Level.SEVERE, null, ex);
            } catch (TagException ex) {
                Logger.getLogger(MainPanel.class.getName()).log(Level.SEVERE, null, ex);
            }
  • 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-07T05:45:09+00:00Added an answer on June 7, 2026 at 5:45 am

    Pre-JDK 7 all you can do is write a utility function and call it from each of the catch blocks:

    private void handle(Exception ex) {
        Logger.getLogger(MainPanel.class.getName()).log(Level.SEVERE, null, ex);
    }
    
    private void someOtherMethod() {
        try {
            // something that might throw
        } catch (CannotReadException ex) {
            handle(ex);
        } catch (ReadOnlyFileException ex) {
            handle(ex);
        } catch (IOException ex) {
            handle(ex);
        } catch (InvalidAudioFrameException ex) {
            handle(ex);
        } catch (TagException ex) {
            handle(ex);
        }
    }
    

    Starting in JDK 7, you can use multi-catch:

    private void someOtherMethod() {
        try {
            // something that might throw
        } catch (CannotReadException | ReadOnlyFileException | IOException
                 | InvalidAudioFrameException | TagException ex) {
            Logger.getLogger(MainPanel.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    

    See “Catching multiple exceptions“.

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

Sidebar

Related Questions

Recently I have been dealing with windows LogonUser API. The LogonUser api returns different
I am dealing with following case. I have a base class that have the
Other questions dealing with use of match_parent pre 2.2 have answers stating one should
I'm dealing with a midlet in j2me, and I have this thread class (say
I am dealing with Cell and I have a problem because they are not
When dealing with something like a List<string> you can write the following: list.ForEach(x =>
Suppose you're dealing with data organized in the following format: [123]=some string [234]=999999999 [345]=some
Following scheme works fine dealing with strings/primitives. But when dealing with lists it gives
I'm dealing with a null pointer exception for which I have a stack trace.
Still dealing with quirky files (see my previous post ), I am using SED

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.