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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:15:55+00:00 2026-05-24T22:15:55+00:00

I am creating a game engine using Java and Mozilla Rhino, and I want

  • 0

I am creating a game engine using Java and Mozilla Rhino, and I want all errors to call one function and provide it with the error message, like

...
} catch(Exception e) {
    Abort(e);
}
...
public void Abort(str) {
    System.out.println("Script error in "current_script_name+" line: "+line_number\n\n"+e);
}

This is easy for RhinoException, but I want to have the same thing for others, like IOException.

  • 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-24T22:15:56+00:00Added an answer on May 24, 2026 at 10:15 pm

    It depends a bit how the exceptions are being thrown, so I’ll need to take a guess. And it depends on the optimization level you’re using to execute Rhino.

    I am guessing that exceptions are being thrown out of native Java code (i.e., you are not using throw new Packages.java.io.IOException("...")). In that case, you can use printStackTrace() to figure it out. Here’s a little script (named test.jsh.js, which you will see in the stack trace) you can run in the Rhino shell:

    try {
        //  foo does not exist
        var stream = new Packages.java.io.FileInputStream("foo");
    } catch (e) {
        e.rhinoException.printStackTrace();
    }
    

    … and its output:

    $ java -jar $(cygpath -w /opt/java/rhino/1.7R2/js.jar) -opt -1 test.jsh.js
    org.mozilla.javascript.WrappedException: Wrapped java.io.FileNotFoundException: foo (The system cannot find the file specified) (test.jsh.js#4)
            at org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1773)
            at org.mozilla.javascript.MemberBox.newInstance(MemberBox.java:202)
            at org.mozilla.javascript.NativeJavaClass.constructSpecific(NativeJavaClass.java:281)
            at org.mozilla.javascript.NativeJavaClass.construct(NativeJavaClass.java:200)
            at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:3377)
            at script(test.jsh.js:4)
            at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2487)
            at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164)
            at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:398)
            at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3065)
            at org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:175)
            at org.mozilla.javascript.tools.shell.Main.evaluateScript(Main.java:564)
            at org.mozilla.javascript.tools.shell.Main.processFileSecure(Main.java:486)
            at org.mozilla.javascript.tools.shell.Main.processFile(Main.java:452)
            at org.mozilla.javascript.tools.shell.Main.processSource(Main.java:443)
            at org.mozilla.javascript.tools.shell.Main.processFiles(Main.java:196)
            at org.mozilla.javascript.tools.shell.Main$IProxy.run(Main.java:117)
            at org.mozilla.javascript.Context.call(Context.java:515)
            at org.mozilla.javascript.ContextFactory.call(ContextFactory.java:507)
            at org.mozilla.javascript.tools.shell.Main.exec(Main.java:179)
            at org.mozilla.javascript.tools.shell.Main.main(Main.java:157)
    Caused by: java.io.FileNotFoundException: foo (The system cannot find the file specified)
            at java.io.FileInputStream.open(Native Method)
            at java.io.FileInputStream.(Unknown Source)
            at java.io.FileInputStream.(Unknown Source)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
            at java.lang.reflect.Constructor.newInstance(Unknown Source)
            at org.mozilla.javascript.MemberBox.newInstance(MemberBox.java:194)
            ... 18 more
    

    If you really want to use exactly the Abort() function you have above, you can parse the appropriate line out of the stack trace above; alternatively, you can display the whole stack trace, which may be more helpful, depending what you want to do.

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

Sidebar

Related Questions

Im currently creating a tile-based game for android. Using java via dalvik JVM. im
I'm creating a game engine using wxWidgets and OpenGL. I'm trying to set up
I am creating a game using the irrlicht c++ 3D graphics engine port to
I've already written a game engine in java using eclipse and opengl es, I
I'm creating a dice game for the iPhone. I'm using SIO2 as engine, but
I am creating a game using cocos2d. Now what I want is I need
I am creating a C++ SDL game engine, and it is relevant to know
I'm in the process of writing a Java 2D game. I'm using the built-in
I'm making a game engine in C++. It is supposed to read all its
I'm currently building a tool for my game engine using WPF. The tool is

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.