Currently, I've modified Laz_And_Controls jAsyncTask to become like bellow, because I'm too lazy to make try..except on every task. Not just that, I add "keepInBackground := False", because adding that into every task doesn't look makes sense to me.
procedure jAsyncTask.GenEvent_OnAsyncEventDoInBackground(Obj: TObject; progress: integer; out keepInBackground: boolean);
begin
keepInBackground:= True;
fExceptStr := '';
try
if Assigned(FOnDoInBackground) then
FOnDoInBackground(Obj,progress,keepInBackground);
keepInBackground := False;
except
on e: exception do
begin
keepInBackground := False;
fExceptStr := e.Message;
end;
end;
end;
procedure jAsyncTask.GenEvent_OnAsyncEventPostExecute(Obj: TObject; progress: Integer);
begin
if fExceptStr <> '' then
gApp.ShowMessage('ASyncTask Exception Error', fExceptStr, 'OK');
if Assigned(FOnPostExecute) then FOnPostExecute(Obj,progress);
end;
But still, the kinda unsatisfying result happens, it doesn't handle nil variable. It's okay for now because it handles most exceptions except the Access Violation.
I was trying to look to any LAMW sources because there's no loop in the jApp (everything handled by events) so jApp.OnException is impossible to use.
I've tried in
this thread to modify the App.java template, but I have no idea because I don't speak Java. Maybe someone can tell me how to use this?
Does anyone have an idea?
Thank you.