aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/erl_nif.c
diff options
context:
space:
mode:
authorSteve Vinoski <[email protected]>2015-04-27 23:39:37 -0400
committerSteve Vinoski <[email protected]>2015-05-26 11:13:16 -0400
commit884afd8efb8672df2889df98b5b94f3dbb53952c (patch)
treef12032760444836964397d4a30869aed2a656c43 /erts/emulator/beam/erl_nif.c
parent2f38cce79ae1bf318cdc8884bd74d1407778d91d (diff)
downloadotp-884afd8efb8672df2889df98b5b94f3dbb53952c.tar.gz
otp-884afd8efb8672df2889df98b5b94f3dbb53952c.tar.bz2
otp-884afd8efb8672df2889df98b5b94f3dbb53952c.zip
Enhance enif_has_pending_exception
Sverker Eriksson came up with the following idea: to handle a future ability for NIFs to raise more than just badarg exceptions, modify the recently-added enif_has_pending_exception function to take a second argument: a pointer to ERL_NIF_TERM. If this argument is a null pointer, ignore it. Otherwise, if the first argument, an ErlNifEnv*, has an associated exception, set the pointed-to ERL_NIF_TERM of the second argument to the value of the exception term. Add new tests and documentation for this modification.
Diffstat (limited to 'erts/emulator/beam/erl_nif.c')
-rw-r--r--erts/emulator/beam/erl_nif.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/erts/emulator/beam/erl_nif.c b/erts/emulator/beam/erl_nif.c
index 7876785a76..36da6519f7 100644
--- a/erts/emulator/beam/erl_nif.c
+++ b/erts/emulator/beam/erl_nif.c
@@ -741,8 +741,11 @@ Eterm enif_make_badarg(ErlNifEnv* env)
BIF_ERROR(env->proc, BADARG);
}
-int enif_has_pending_exception(ErlNifEnv* env)
+int enif_has_pending_exception(ErlNifEnv* env, ERL_NIF_TERM* reason)
{
+ if (env->exception_thrown && reason != NULL) {
+ *reason = am_badarg;
+ }
return env->exception_thrown;
}