diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2018-02-07 15:24:29 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2018-02-13 13:48:36 +0100 |
commit | 9a2db67519ad2ec625a1b7c6526353e202c14d2d (patch) | |
tree | 1045f3b795a4ba7a54a672530a5802e86c9cd414 /ffi/examples | |
parent | 73c02452ee5a8d29c5df5c67cd775755b3b8d64c (diff) |
ffi: Improve error reporting.
- Add a new type ffi::Context that provides an error slot.
- Functions that can return complex errors can stash the error
there, while still be convenient to use.
- For now, there is only sq_last_strerror that returns a string
representation of the error. In the future we should also return
a numeric code, and may want to expose the stack of failures.
Diffstat (limited to 'ffi/examples')
-rw-r--r-- | ffi/examples/example.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/ffi/examples/example.c b/ffi/examples/example.c index 5b087c15..a9de1856 100644 --- a/ffi/examples/example.c +++ b/ffi/examples/example.c @@ -37,9 +37,9 @@ main (int argc, char **argv) if (b == MAP_FAILED) error (1, errno, "mmap"); - tpk = sq_tpk_from_bytes (b, st.st_size); + tpk = sq_tpk_from_bytes (ctx, b, st.st_size); if (tpk == NULL) - error (1, 0, "sq_tpk_from_bytes failed"); + error (1, 0, "sq_tpk_from_bytes: %s", sq_last_strerror (ctx)); sq_tpk_dump (tpk); sq_tpk_free (tpk); |