Currently managed delegates that throw exceptions result in undefined behavior (I expect they would crash sqlite). We could give delegates the ability to throw a SQLiteException instead and grab the error code and message, passing these to sqlite3_result_error and sqlite3_result_error_code. For other exceptions its not clear what we should do.