A guide to retrieving the Java exception behind a ScriptException in JSR-223

My current setup involves running Javascripts through the JSR-223 script engine within JRE6. These scripts have the ability to access Java code and objects. In case an exception is generated by the Java code called from a JavaScript, the ScriptEngine will throw a ScriptException.

I am aiming to retrieve the Java exception that triggered the JavaScript exception.

In the JavaScript, I can catch the exception and check the javaException field of the exception:

try
{
  .
}
catch (e)
{
  e.javaException.printStackTrace();
}

Unfortunately, I do not have direct control over the JavaScript itself, only its execution via the ScriptEngine. Is there a method to obtain the "inner" Java exception from the ScriptException?

It seems that if I were using Rhino, the RhinoException may have included a Java exception. However, the RhinoException is not accessible through the JSR-223 API.

Answer №1

Have you tested the e.getCause() method?

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

"Oops! Encountered a hiccup while setting up SparkContext - Java, Eclipse, and Spark

Just starting out with Spark and experimenting with some example projects. Currently, I'm working on a project that involves reading from a CSV file. However, I encountered an error when running the app. The Eclipse console displayed the following mes ...

What is the significance of static in react?

export class NavMenu extends Component { static displayName = NavMenu.name; constructor (props) { super(props); this.toggleNavbar = this.toggleNavbar.bind(this); this.state = { collapsed: true }; } I attempted to research the ...

ThreeJS Loading Page

Just starting out with ThreeJS and currently in the process of building a 3D Configurator. I'm looking to add a loading screen before the obj object loads, here's my current code: <!DOCTYPE html> </style> </head> <body& ...

Achieving success in element-ui vuejs involves validating the state with the :error parameter

I recently developed an app using Laravel, Vuejs, and Element-ui. Within my form, I have utilized the "error" property to indicate that Laravel validation is in place. <el-form-item label="First Name" prop="firstname" :error="registerForm.errors.get(&a ...

Utilize viewport activation to determine browser width

Is there a way to dynamically add the viewport-meta tag only for devices with screen widths larger than 680px? If the screen is smaller than 680px, then the responsive style file should be enabled instead. I attempted to achieve this by placing the follow ...

How can I transfer the value of a local variable to a function variable in Three.js JSON Loader?

I am attempting to import an external JSON model into the scene and assign its value to a variable called head, and then add it to the scene. This is what I have done: var loader = new THREE.JSONLoader(); this.head = loader.load( "eagle2.js", fu ...

Assistance in configuring Zurb Foundation 5 for optimal integration with Laravel

As a relatively new user to Laravel with previous experience using older versions of Foundation, I am currently in the process of setting up a new Laravel project. My goal is to integrate the Foundation framework into my project, but I find myself a bit co ...

Is it possible to implement drag and drop functionality for uploading .ply, .stl, and .obj files in an angular application?

One problem I'm facing is uploading 3D models in angular, specifically files with the extensions .ply, .stl, and .obj. The ng2-upload plugin I'm currently using for drag'n'drop doesn't support these file types. When I upload a file ...

AngularJS directive for automatically resizing Dygraph on page load

Could someone please assist me with resizing my graph inside tabs using Angular? When I initially load the graphs, they don't display unless I manually resize the window. How can I ensure that the graphs are loaded and fill the div on the first load? ...

Is it important to minify JavaScript npm packages?

In my journey of creating numerous npm packages, I find myself pondering over the question: "Should JavaScript npm packages be minified?" I have always held the belief that minifying already minified code is not a good practice, which is why I have refrai ...

What is the best way to track the initial rendering speed of a React application as it evolves?

My goal is to assess the performance of our react app by running a node script on our CI server with production size data. The objective is to track the performance of our project as the codebase evolves over time. After researching, I was surprised to fi ...

Error encountered: wkhtmltopdf Timeout Issue

I have a unique application that allows users to generate PDFs from HTML using a node server. This application utilizes the wkhtmltopdf 0.12.3-dev-79ff51e engine (with patched qt) integrated with node-wkhtmltopdf module. Occasionally, an error message po ...

"Adjust the placement of a personalized marker on a Google Map using google-map-react

I have incorporated google-map-react into my React project and I have designed custom markers. The markers are displayed at the correct location but from the top left corner: https://i.sstatic.net/e6lGN.png The red dot indicates the exact location. Howe ...

Sending a date through the query string to a SharePoint list view web part

My goal is to filter a list view web part by the "Created" field using the filter parameter value from the query string. I have attempted passing different values in various ways, such as: For example: .../../samplepage.aspx?startDate=2016-11-01T18%3a55%3 ...

Correcting Typing Errors in TypeScript

My current challenge involves a method that is consuming data from an external API: public async getStatus(id: string): Promise<APIRes | undefined> { try { const result = await getRequest(`${this.URL}/endpoint/${id}`) const respo ...

nuxt-auth is experiencing difficulties retrieving token information through the refresh provider

I'm currently facing challenges with the login functionality in Nuxt 3. To handle user authentication, I've installed the package @sidebase/nuxt-auth. Below are my configurations set in the file nuxt.config.ts: auth: { globalAppMiddleware: t ...

What is the best way to organize my Java Selenium tests into individual classes?

Currently, I am engaged in GUI testing at my workplace by utilizing Selenium 2 with Java in Eclipse. To enhance code reusability, I have developed numerous helper methods resembling a framework within my test class. However, this has caused the test class ...

There is a lack of 'Access-Control-Allow-Origin' header, resulting in no access to the API

Having some trouble with the UK Parliament API, I keep encountering this error: XMLHttpRequest cannot load . No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://example.com' is therefore not a ...

Having trouble with my inline CSS not working with the NextJS Image component

Why am I unable to style the Image component in NextJS to manipulate my image? Am I overlooking something? <Image className={styles.bg} style={{ transform: `translateY(${offset * 0.5}px)` }} src="/../public/bg.jpg" // ...

Adding a character at the current cursor position in VUE JS

My quest for inserting emojis in a textarea at the exact cursor position has led me to an extensive search on Vue JS techniques. However, most resources available online provide solutions using plain Javascript. Here is the code snippet I am working with: ...