>I wasn't sure if it would work, so I tried calling ErrThrow in a
>shared library
>routine and catching it in the calling function in the main application.
>
>It worked just fine!
>
>Does that mean it's ok to do, or does anyone know of restrictions or
>circumstances
>where it won't work, and I just got lucky?
If you're guaranteed that errors are being thrown from your library
to your app, then it should work. The ErrThrow mechanism uses the
throw handler chain that's referenced from the current app's
SysAppInfoType structure, thus allowing an exception to jump across
the app/shared lib boundary. The other key point is that the library
trap dispatcher doesn't do any cleanup after the library call returns
(the library routine returns directly to the caller), so throwing an
exception doesn't skip any critical OS code.
In some of the shared library code I've written (e.g. to support
globals) the top-level routines _must_ execute some cleanup code to
restore the library state correctly, so in that case throwing an
exception out of the bowels of a library doesn't work. I had to
install exception handlers in each of the top-level routines, which
execute the cleanup code and then rethrow the exception.
-- Ken
Ken Krugler
TransPac Software, Inc.
<http://www.transpac.com>
+1 530-470-9200
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/