I expect the following output in a browser console:
Begin
Error: sys::ArgErr: Hello!
End
But the browser throws a native exception, which is similar to the following:
Begin
Uncaught exception:
Error thrown at line 27, column 6 in <anonymous function: fan.hello.helloApp.main>(args) in http://localhost:8080/pod/hello/hello.js:
throw $_u1;
called from line 2, column 45 in <anonymous function: window.onload>() in http://localhost:8080/:
fan.hello.helloApp.main();
Here is a compiled javascript code of the example:
fan.sys.ObjUtil.echo("Begin");
try
{
throw fan.sys.ArgErr.make("Hello!");
}
catch ($_u1)
{
$_u1 = fan.sys.Err.make($_u1);
if ($_u1 instanceof fan.sys.ArgErr)
{
var e = $_u1;
var e;
fan.sys.ObjUtil.echo(fan.sys.Str.plus("Error:",e));
}
else
{
throw $_u1; // <-- THE EXCEPTION IS THROWN FROM HERE
}
}
;
fan.sys.ObjUtil.echo("End");
It's a very strange behaviour. It seems like Opera prevents reassignment to $_u1 variable in $_u1 = fan.sys.Err.make($_u1); statement and keeps its original value. It may be enought to fix a "Fantom to JS" compiler" to use another variable to store an instance of Fantom's Error.
andyMon 14 Nov 2011
Is this unique to Opera? Does it work properly in other browsers? Can you post some more debug:
mnasyrov Mon 14 Nov 2011
I have a simple code that throws an exception and catches it. But it does not work in Opera 11.52 and Fantom 1.0.60.
The source code:
I expect the following output in a browser console:
But the browser throws a native exception, which is similar to the following:
Here is a compiled javascript code of the example:
It's a very strange behaviour. It seems like Opera prevents reassignment to
$_u1
variable in$_u1 = fan.sys.Err.make($_u1);
statement and keeps its original value. It may be enought to fix a "Fantom to JS" compiler" to use another variable to store an instance of Fantom's Error.andy Mon 14 Nov 2011
Is this unique to Opera? Does it work properly in other browsers? Can you post some more debug:
mnasyrov Tue 15 Nov 2011
Yes, my example doesn't work in Opera and works in Chrome, Safari, FireFox and IE9.
Andy, Opera prints
Error: sys::Err
for your code, while other browsers printsError: sys::ArgErr
.andy Tue 15 Nov 2011
Promoted to ticket #1698 and assigned to andy
andy Thu 8 Jun 2017
Ticket cancelled
Cancelling since Opera is now based on Chromium