diff options
author | Szczepan Zalega <szczepan@nitrokey.com> | 2016-08-09 15:33:26 +0200 |
---|---|---|
committer | Szczepan Zalega <szczepan@nitrokey.com> | 2016-08-09 18:34:00 +0200 |
commit | ba4d36c38c0017415129a5674c0f7133e6d76f9d (patch) | |
tree | 8f96d247300f66df1ec5bf5cba3e56db903509a4 /NK_C_API.cc | |
parent | 9d6e045a3143f8eb31c5033c9c4be59cc2f73336 (diff) | |
download | libnitrokey-ba4d36c38c0017415129a5674c0f7133e6d76f9d.tar.gz libnitrokey-ba4d36c38c0017415129a5674c0f7133e6d76f9d.tar.bz2 |
Return error on invalid slot
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'NK_C_API.cc')
-rw-r--r-- | NK_C_API.cc | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/NK_C_API.cc b/NK_C_API.cc index 4ba29ab..ea63f36 100644 --- a/NK_C_API.cc +++ b/NK_C_API.cc @@ -23,8 +23,8 @@ uint8_t * get_with_array_result(T func){ catch (CommandFailedException & commandFailedException){ NK_last_command_status = commandFailedException.last_command_status; } - catch (TooLongStringException & longStringException){ - NK_last_command_status = TooLongStringException::exception_id; + catch (LibraryException & libraryException){ + NK_last_command_status = libraryException.exception_id(); } return nullptr; } @@ -38,8 +38,8 @@ const char* get_with_string_result(T func){ catch (CommandFailedException & commandFailedException){ NK_last_command_status = commandFailedException.last_command_status; } - catch (TooLongStringException & longStringException){ - NK_last_command_status = TooLongStringException::exception_id; + catch (LibraryException & libraryException){ + NK_last_command_status = libraryException.exception_id(); } return ""; } @@ -53,8 +53,8 @@ auto get_with_result(T func){ catch (CommandFailedException & commandFailedException){ NK_last_command_status = commandFailedException.last_command_status; } - catch (TooLongStringException & longStringException){ - NK_last_command_status = TooLongStringException::exception_id; + catch (LibraryException & libraryException){ + NK_last_command_status = libraryException.exception_id(); } return static_cast<decltype(func())>(0); } @@ -68,12 +68,11 @@ uint8_t get_without_result(T func){ } catch (CommandFailedException & commandFailedException){ NK_last_command_status = commandFailedException.last_command_status; - return commandFailedException.last_command_status; } - catch (TooLongStringException & longStringException){ - NK_last_command_status = TooLongStringException::exception_id; - return NK_last_command_status; + catch (LibraryException & libraryException){ + NK_last_command_status = libraryException.exception_id(); } + return NK_last_command_status; } extern "C" |