uqbar-project / wollok

Wollok Programming Language
GNU General Public License v3.0
60 stars 16 forks source link

Exception in Native methods are not correctly mapped to wollok.lang.Exception therefore resulting in a complex stacktrace #454

Closed asanzo closed 8 years ago

asanzo commented 8 years ago

El error para cuando no se entiende un mensaje:

org.uqbar.project.wollok.interpreter.WollokInterpreterException: Error evaluating line file:/opt/wollok/workspace/SuperSmashBros/src/testsSmashBros.wtest:[7]: assert.equals(cpnFalcon.sasdfasdfasdfasdfasdfasdf(),9999)

Es igual a un error aritmético:

org.uqbar.project.wollok.interpreter.WollokInterpreterException: Error evaluating line file:/opt/wollok/workspace/SuperSmashBros/src/testsSmashBros.wtest:[10]: 43242 / 0

¿Podría tener un stacktrace diferente? Lo único que me sirve de todo eso es la línea donde ocurrió el error....

javierfernandes commented 8 years ago

This has been addressed in the last weeks for Wollok 1.3

See here https://github.com/uqbar-project/wollok/issues/429

You can try it out by installing the latest "dev" version or updating by using the update site:

http://update.uqbar.org/wollok/dev

asanzo commented 8 years ago

True, message not understood now it's detected before test run.

But other execution errors still get unexplained. For example, a divide by zero still gets "Error evaluating line"

org.uqbar.project.wollok.interpreter.WollokInterpreterException: Error evaluating line file:/opt/wollok/workspace/SuperSmashBros/src/testsSmashBros.wtest:[7]: assert.equals(cpnFalcon.potencialOfensivo(),9999/0)

javierfernandes commented 8 years ago

Cool, good point ! I believe in that particular case we are talking about exception propagation for native objects (the / op in integers). I'll fix that. This is part of a really big refactor we are doing right now to isolate wollok from java (interpreter)

javierfernandes commented 8 years ago

Fixed in dev !

Now if a native method (like integer's methods or collections, etc) throw a java exception wollok will convert it automatically to a wollok.lang.Exception and throw it through the wollok exception handling mechanism, so you will actually be able to catch it if you want. But if you don't it means that it will be shown as any other wollok exception.

For example in your case it will show something like this

wollok.lang.Exception: / by zero
    at  [/wollok.wlk:408]
    at  [__synthetic0.wpgm]