OnException is specific to Object Pascal code exceptions.
OnError catches everything, also underlying JavaScript related error. It doesn't do deeper checks on the error type.
then ... if OnError catches everything (Pascal and JS exceptions) why when I raise Exception.Create('Error from raise') I get an exception object with AMessage Uncaught [object Object] but not Error from raise ?
The console.log(AError.AMessage) in procedure AppError is Uncaught [object Object] not Error from raise
procedure source below:
procedure TForm1.AppError(Sender: TObject; AError: TApplicationError; var Handled:Boolean);
begin
Handled:=True;
console.log(AError.AMessage);
end;
Ok ... thank you ... I think that this is transpiler releated too, but maybe good idea will be ask pas2js team by the way additionally about await version.
For example:
procedure TForm1.wbtn3Click(Sender: TObject);
begin
await(aaa);
end;
procedure TForm1.aaa;
begin
//JS Exception
console.log(document.getElementById('aaa').id);
//Pascal raise Exception
raise Exception.Create('Error Message from await');
end;
Never mind if inside async procedure I raise error via
raise Exception.Create('Error Message from await');
or js error
console.log(document.getElementById('aaa').id);
The Application.OnError procedure and console.log(AError.AMessage) return Undefined Javascript Exception which is wrong too.
Should be for JS Exception "Cannot read properties of null (reading 'id')" and for Pascal Exception "Error Message from await"
Thank you for wanting to address this as the use Application.OnError (single point for app error handling) doesn't make sense at the moment.