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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:58:37+00:00 2026-05-25T23:58:37+00:00

Short form: How do you throw exceptions (or do nice, clean exception handling; or

  • 0

Short form: How do you throw exceptions (or do nice, clean exception handling; or at least dirtily force execution to stop) when the overridden method doesn’t throw exceptions?

Context: We have a license for a piece of proprietary software that can be automated using Java “macros”. A user-defined macro must be of this form:

public class MyMacro extends SoftwareMacro {
    public void execute() {
        // user code goes here
    }
}

i.e. a class that extents SoftwareMacro and that has a method called execute that overrides the base class’ execute. The contents of this overriding execute are what gets… well… executed when the macro is “played”.

But the overridden execute method apparently does not throw any exceptions.

execute() in com.mycompany.mypackage.MyMacro cannot implement execute() in 
somesoftware.base.SoftwareMacro
overridden method does not throw java.lang.Exception

Maybe this is naïve, but while developing I usually like to have the appropriate exception type bubble up to the top and force execution to stop, so that I can see them and go on to debug. This is apparently not an option here.

Should I resort to throwing RuntimeException instead? (since RuntimeException does not need to be specified) That feels a bit sloppy, and a “violation in spirit” of the base class method contracy.

P.S. No, I can’t change the source code of the overriden execute method.

  • 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-25T23:58:38+00:00Added an answer on May 25, 2026 at 11:58 pm

    Looks like the intent is that each SoftwareMacro do all its own error handling. Use a big try around your whole execute() method if need be, but don’t let any exceptions escape. Do whatever cleanup you need to do inside your execute method, and possibly print an error message for the user, if they provide a way to do that.

    You should examine all the APIs they provide — perhaps there’s an error reporting facility you’re supposed to use.

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

Sidebar

Related Questions

I'm trying to figure out what the correct form of exceptions to throw would
The short form of this question: When, if ever, is it appropriate to use
Short version: I want to trigger the Form_Load() event without making the form visible.
Short of inserting a try/catch block in each worker thread method, is there a
SHORT FORM(!) In response the Jon Skeet's comment, what I want C# to be
In an earlier post I asked about how to create short form for my
My VB6 project requires keyboard short-cuts for toolbar control in its MDI Form. For
Long story short: on Chrome and Safari only, values from a login form are
I have a repository method that accepts an order by parameter in the form:
:vsplit (short form: :vs ) split the Vim viewport vertically. :30vs splits the viewport,

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.