Recent

Author Topic: Handle exceptions on android  (Read 2836 times)

Rang

  • Newbie
  • Posts: 3
Handle exceptions on android
« on: December 18, 2018, 09:48:42 am »
How can i handle exceptions on android with using self procedure?

On windows working this:
Code: Pascal  [Select][+][-]
  1. ExceptProc := @MyExceptHandler;
  2. SetErrorMode(SEM_NOGPFAULTERRORBOX);
  3.  

SetErrorMode is windows only procedure.

Is there solution for android\linux?
I need hadle all exceptions in application (native library in android).

Thaddy

  • Hero Member
  • *****
  • Posts: 14197
  • Probably until I exterminate Putin.
Re: Handle exceptions on android
« Reply #1 on: December 18, 2018, 11:05:29 am »
Simply include sysutils and handle with try/except/on ExxxException. The only exception on Android that would try to show a possible exception dialog is EOutOfMemory.
That's different from Windows, so AFAIK you don't need to suppress the GP dialog on Android. The above dialog can be suppressed by handling it yourself and drop it. After all it is fatal.
« Last Edit: December 18, 2018, 11:12:43 am by Thaddy »
Specialize a type, not a var.

Rang

  • Newbie
  • Posts: 3
Re: Handle exceptions on android
« Reply #2 on: December 18, 2018, 11:50:32 am »
Simply include sysutils and handle with try/except/on ExxxException. The only exception on Android that would try to show a possible exception dialog is EOutOfMemory.
That's different from Windows, so AFAIK you don't need to suppress the GP dialog on Android. The above dialog can be suppressed by handling it yourself and drop it. After all it is fatal.

I need global handler for exceptions, on it i sending report to server with error description, and show simple info for user.
I tryed this:
Code: Pascal  [Select][+][-]
  1. ExceptProc := @MyExceptHandler;
But on android thats not work. MyExceptHandler not called.

On windows, as shown above, all work fine, but there one more line with: SetErrorMode(SEM_NOGPFAULTERRORBOX);

cpalx

  • Hero Member
  • *****
  • Posts: 753
Re: Handle exceptions on android
« Reply #3 on: December 18, 2018, 10:08:10 pm »
I think, is in Delphi mode, try

Code: Pascal  [Select][+][-]
  1. ExceptProc := MyExceptHandler;
« Last Edit: December 18, 2018, 10:21:20 pm by cpalx »

Rang

  • Newbie
  • Posts: 3
Re: Handle exceptions on android
« Reply #4 on: December 18, 2018, 10:46:12 pm »
I think, is Delphi mode, try

Code: Pascal  [Select][+][-]
  1. ExceptProc := MyExceptHandler;

Does not help. :(
Tried this variant.
And yes, Delphi mode by default for all project (-MDelphi).

 

TinyPortal © 2005-2018