Notes on using lib_trycatch

Technical questions regarding the xTIMEcomposer, xSOFTip Explorer and Programming with XMOS.
User avatar
johned
XCore Addict
Posts: 158
Joined: Tue Mar 26, 2013 12:10 pm
Contact:

Notes on using lib_trycatch

Postby johned » Tue Feb 20, 2018 6:29 pm

The XMOS Try/Catch library https://www.xmos.com/support/libraries/lib_trycatch can be used to catch exceptions.

Handling exceptions correctly avoids the core sitting in the trap handler.

Example of catching an application thrown exception: https://github.com/xmos/lib_trycatch/blob/master/tests/throw_xc/src/main.xc

Example of catching a hardware exception:
https://github.com/xmos/lib_trycatch/blob/master/tests/divide_zero_xc/src/main.xc

The limitation is that lib_trycatch won’t attempt to free any resources allocated inside the try block or return any variables to their original state in the event of an exception being raised. See https://github.com/xmos/lib_trycatch/blob/master/README.rst for more details.
User avatar
andrew
Experienced Member
Posts: 113
Joined: Fri Dec 11, 2009 10:22 am

Postby andrew » Thu May 03, 2018 8:50 am

Thanks John

Who is online

Users browsing this forum: ZrogkoolT and 52 guests