Pas2JS pascal source code
{ main.pas }
var e: string;
Begin
try
WriteLn('ok');
except
on e: EDelphi do
begin
WriteLn(EDelphi(e).ClassName);
end;
on e: Exception do
WriteLn(e.ClassName);
end;
{ <<< CONSOLE OUTPUTS >>>
ok
}
var Exception={
$ClassName: "Exception",
$Parent: TObject,
$Init: function () { FMessage="" },
Create: function (s,Msg) { s.FMessage=Msg; return s }
}
function $W(e) { return e.ClassType?e:Exception.Create($New(Exception),e.constructor.name+", "+e.message) }
function $ToClassType(o) {
if (o===null) return o;
return o.ClassType
};
function $New(c) { var i={ClassType:c}; c.$Init(i); return i }
function $Is(o,c) {
if (o===null) return false;
return $Inh(o.ClassType,c);
};
function $Inh(s,c) {
if (s===null) return false;
while ((s)&&(s!==c)) s=s.$Parent;
return (s)?true:false;
};
var e = "";
try {
WriteLn("ok");
} catch ($e) {
if ($Is($e,EDelphi)) {
var e$1 = $W($e);
WriteLn(ClassName$1($ToClassType(e$1))) }
else if ($Is($e,Exception)) {
var e$2 = $W($e);
WriteLn(ClassName$1($ToClassType(e$2))) }
else throw $e
}