diff options
author | Jack Lloyd <[email protected]> | 2018-02-07 17:46:38 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-02-07 17:46:38 -0500 |
commit | 3d868667ab5a29c31acde34c22b5b4176619260e (patch) | |
tree | e601c3edfe0f1e79f3ed4c3a6898f8130d576ec2 /src/lib/ffi/ffi.cpp | |
parent | dc5b0ab629942d6675f70b5450f7fd12c05320ed (diff) |
Make FFI errors an enum, and add a function to translate to strings
Diffstat (limited to 'src/lib/ffi/ffi.cpp')
-rw-r--r-- | src/lib/ffi/ffi.cpp | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/src/lib/ffi/ffi.cpp b/src/lib/ffi/ffi.cpp index 39749c4d4..ecc8d2899 100644 --- a/src/lib/ffi/ffi.cpp +++ b/src/lib/ffi/ffi.cpp @@ -26,6 +26,50 @@ extern "C" { using namespace Botan_FFI; +const char* botan_error_description(int err) + { + switch(err) + { + case BOTAN_FFI_SUCCESS: + return "OK"; + + case BOTAN_FFI_INVALID_VERIFIER: + return "Invalid verifier"; + + case BOTAN_FFI_ERROR_INVALID_INPUT: + return "Invalid input"; + + case BOTAN_FFI_ERROR_BAD_MAC: + return "Invalid authentication code"; + + case BOTAN_FFI_ERROR_INSUFFICIENT_BUFFER_SPACE: + return "Insufficient buffer space"; + + case BOTAN_FFI_ERROR_EXCEPTION_THROWN: + return "Exception thrown"; + + case BOTAN_FFI_ERROR_BAD_FLAG: + return "Bad flag"; + + case BOTAN_FFI_ERROR_NULL_POINTER: + return "Null pointer argument"; + + case BOTAN_FFI_ERROR_BAD_PARAMETER: + return "Bad parameter"; + + case BOTAN_FFI_ERROR_NOT_IMPLEMENTED: + return "Not implemented"; + + case BOTAN_FFI_ERROR_INVALID_OBJECT: + return "Invalid object handle"; + + case BOTAN_FFI_ERROR_UNKNOWN_ERROR: + return "Unknown error"; + } + + return "Unknown error"; + } + /* * Versioning */ @@ -120,4 +164,3 @@ int botan_base64_decode(const char* base64_str, size_t in_len, } } - |