Pas2JS pascal source code
type
MyException = class(Exception);
type
OtherException = class(Exception)
end;
{ main.pas }
Begin
try
raise MyException.Create('exception message');
except
on e: MyException do
WriteLn('MyException: ' + e.Message);
on e: OtherException do
WriteLn('OtherException: ' + e.Message);
else
WriteLn('Else');
end;
try
raise OtherException.Create('exception message');
except
on e: MyException do
WriteLn('MyException: ' + e.Message);
on e: OtherException do
WriteLn('OtherException: ' + e.Message);
else
WriteLn('Else');
end;
try
raise Exception.Create('exception message 1');
except
on e: MyException do
WriteLn('MyException: ' + e.Message);
on e: OtherException do
WriteLn('OtherException: ' + e.Message);
else
WriteLn('Else');
end;
try
raise OtherException.Create('exception message 2');
except
on e: Exception do
WriteLn('MyException: ' + e.Message);
else
WriteLn('Invisible');
end;
var
t := True;
try
try
if t then
raise Exception.Create('exception message 3');
WriteLn('Invisible');
finally
WriteLn('Finally');
end;
WriteLn('Invisible');
except
WriteLn('Except');
end;
{ <<< CONSOLE OUTPUTS >>>
MyException: exception message
OtherException: exception message
Else
MyException: exception message 2
Finally
Except
}
end;