September 26, 2022, 07:46:32 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Exceptions handling

Started by sapero, November 08, 2006, 04:31:26 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

efgee

Is exception handling now build in into Aurora?
If so what is the syntax, same as sapero's examples?

Also:
Quote from: Paul Turley on January 06, 2007, 08:14:22 PM
See my post in the developers forum. 

looked for more info but to no avail.

Brice Manuel

Quote from: efgee on July 16, 2007, 05:04:06 PMlooked for more info but to no avail.
You do not have access to that forum as you are not a developer.

efgee

So is it implemented or not?

Ionic Wind Support Team

Ionic Wind Support Team

sapero

I have updated it a bit for use with multiple threads.
The __try function creates a TLS slot, and in this slot stores a pointer to newly, from heap allocated bufer with EXCEPTION_POINTERS, EXCEPTION_RECORD and CONTEXT structures. Having these structures separate for each running thread, I could add two usefull functions: GetExceptionCode and GetExceptionInformation.
Both functions can be called at any moment, but the data returned will be usefull after the first exception.

GetExceptionInformation can return NULL if the active thread didn't called __try.#include "windows.inc"
#include "gp.inc"
#use "gp.lib"

sub main()
{
unsigned int code, address;
string *info;

if __try()
{
__throw("my message"); // generate exception, custom code 0xEFFFFFFE
}
if __catch(&code, &address, &info)
{
print(hex$(GetExceptionInformation()->ExceptionRecord->ExceptionCode));
print(hex$(GetExceptionCode()));
MessageBox(0, using("& (&) at &", info, hex$(code), hex$(address)),"",0);
}
}


$include "windowssdk.inc"
$include "ebgp.inc"
$use "gp.lib"

uint code, address
pointer info

if __try()
__throw("my message") ' generate exception, custom code 0xEFFFFFFE
endif

if __catch(&code, &address, &info)
pointer pep = GetExceptionInformation()
settype pep, EXCEPTION_POINTERS
print hex$(*pep.*<EXCEPTION_RECORD>ExceptionRecord.ExceptionCode)
print hex$(GetExceptionCode())
MessageBox 0, using("& (&) at &", info, hex$(code), hex$(address)),"",0
endif