From 9d6e045a3143f8eb31c5033c9c4be59cc2f73336 Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Tue, 9 Aug 2016 15:15:17 +0200 Subject: Return error for too long string Signed-off-by: Szczepan Zalega --- NK_C_API.cc | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'NK_C_API.cc') diff --git a/NK_C_API.cc b/NK_C_API.cc index 577f2d6..4ba29ab 100644 --- a/NK_C_API.cc +++ b/NK_C_API.cc @@ -1,5 +1,7 @@ #include #include "NK_C_API.h" +#include "include/TooLongStringException.h" + using namespace nitrokey; static uint8_t NK_last_command_status = 0; @@ -20,8 +22,11 @@ uint8_t * get_with_array_result(T func){ } catch (CommandFailedException & commandFailedException){ NK_last_command_status = commandFailedException.last_command_status; - return nullptr; } + catch (TooLongStringException & longStringException){ + NK_last_command_status = TooLongStringException::exception_id; + } + return nullptr; } template @@ -32,8 +37,11 @@ const char* get_with_string_result(T func){ } catch (CommandFailedException & commandFailedException){ NK_last_command_status = commandFailedException.last_command_status; - return ""; } + catch (TooLongStringException & longStringException){ + NK_last_command_status = TooLongStringException::exception_id; + } + return ""; } template @@ -44,8 +52,11 @@ auto get_with_result(T func){ } catch (CommandFailedException & commandFailedException){ NK_last_command_status = commandFailedException.last_command_status; - return static_cast(0); } + catch (TooLongStringException & longStringException){ + NK_last_command_status = TooLongStringException::exception_id; + } + return static_cast(0); } template @@ -59,6 +70,10 @@ uint8_t get_without_result(T func){ 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; + } } extern "C" -- cgit v1.2.1