Better JavaScript Error Messages

Please log all suggestions for improvements and enhancements to Visual LANSA here. All entries will be acknowledged and added to the list for possible inclusion in later releases of Visual LANSA.
Post Reply
jyoung
Posts: 642
Joined: Thu Jan 21, 2016 6:43 am
Location: Oklahoma City, OK USA

Better JavaScript Error Messages

Post by jyoung » Wed Jan 25, 2017 2:52 am

I think it would be really helpful to have better JavaScript error messages.

For example, I just got this error
Error Capture.PNG
Error Capture.PNG (25.97 KiB) Viewed 2588 times
This makes me think that the error is on MOBApplication Line 11.

But its not.

It is actually in none of the panels listed on the error notification.

I finally discovered it in a widget we use based on the shipped xGoogleMap widget.

This is the code that caused the error:
Error Code Capture.PNG
Error Code Capture.PNG (10.73 KiB) Viewed 2588 times
If you are familiar with JavaScript you may see it pretty quickly.

Here is the corrected code.
Correct Code Capture.PNG
Correct Code Capture.PNG (10.84 KiB) Viewed 2588 times
If the error notification would have told me that is was in the GoogleMapWidget in the AddMarker prototype, I could have found and fixed it in a matter of minutes.

dannyoorburg
Posts: 152
Joined: Mon Jan 04, 2016 9:50 am
Location: Australia

Re: Better JavaScript Error Messages

Post by dannyoorburg » Thu Jan 26, 2017 12:10 pm

Hi Joe,

you fell into the exception that deals with a syntax error in the downloaded JavaScript. It should report exactly which file contains the syntax error, which it currently doesn't, we'll rectify that.

It was never that important for the JavaScript that is compiled RDMLX, because it gets generated and should therefor be syntax error free. But with the introduction of Widgets it should have started reporting a bit better, that's just an oversight.

You probably found that the Visual LANSA IDE is not ideal for editing JavaScript (as it's all about RDMLX of course). You're better off using a simple editor that understands JavaScript syntax when developing Widgets. It would probably have highlighted your missing comma while you were typing and saved you all the headache.

Once again, thanks for sharing, much appreciated.

Danny.

jyoung
Posts: 642
Joined: Thu Jan 21, 2016 6:43 am
Location: Oklahoma City, OK USA

Re: Better JavaScript Error Messages

Post by jyoung » Fri Jan 27, 2017 2:50 am

Hi Danny,

I've been wanting to use an external editor for JavaScript (huge fan of VSCode) for a while now, but have not figured out a way to do it, though to be honest have not given it much effort.

Is the script stored somewhere on the file system that I can edit?

My other thought was to use an external editor to create a JavaScript module and then include that script in the Widget resources and then use the VL editor (Implementation of the widget) to hook the two up. This way the core logic of the script is in the external script and the Implementation is a "proxy" to the script.

How would you go about it?

Thanks,
Joe

dannyoorburg
Posts: 152
Joined: Mon Jan 04, 2016 9:50 am
Location: Australia

Re: Better JavaScript Error Messages

Post by dannyoorburg » Fri Jan 27, 2017 11:17 am

Hi Joe,

Widgets are stored in the Repository, so no, there's no file to edit somewhere,

My widgets have been really small so far, so a simple copy paste of the source code from the IDE into another editor and back was just fine.

Alternatively, your way of externalizing more complex JavaScript into separate files would do the trick too, in that case I would create an External Resource to manage the file for me, so at least the deployment is managed by LANSA.

If you find yourself writing lots of JavaScript let us know why, the idea is that you should be able to do it all in RDMLX, unless you want to integrate 3rd party widgets.

Cheers,
Danny

Post Reply