From 5b03fb395ce65bcc4aaf860f9be9c7a4c4d6a52c Mon Sep 17 00:00:00 2001 From: yorickdewid Date: Tue, 1 Mar 2016 20:52:47 +0100 Subject: [PATCH] Catch all exceptions --- iban.cc | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/iban.cc b/iban.cc index cf55b3a..f0a0e9c 100644 --- a/iban.cc +++ b/iban.cc @@ -391,14 +391,29 @@ Validate::Validate() { } +/** +* Separate CXX and C logic to minimize unexpected or malformed symbols due to +* language conversions. Also catch all exceptions the std++ can throw since +* PostgreSQL is not able to handle them. +* +* @param {string} iban +* @returns {bool} +*/ namespace { bool account_validate(text *iban) { char *ciban; + bool result; Validate val; ciban = text_to_cstring(iban); - return val.isValid(std::string(ciban)); + try { + result = val.isValid(std::string(ciban)); + } catch (std::exception& e) { + elog(ERROR, "%s", e.what()); + } + + return false; } }