diff options
author | qrort <qrort@yandex-team.com> | 2022-11-30 23:47:12 +0300 |
---|---|---|
committer | qrort <qrort@yandex-team.com> | 2022-11-30 23:47:12 +0300 |
commit | 22f8ae0e3f5d68b92aecccdf96c1d841a0334311 (patch) | |
tree | bffa27765faf54126ad44bcafa89fadecb7a73d7 /library/c/tvmauth/src/exception.h | |
parent | 332b99e2173f0425444abb759eebcb2fafaa9209 (diff) | |
download | ydb-22f8ae0e3f5d68b92aecccdf96c1d841a0334311.tar.gz |
validate canons without yatest_common
Diffstat (limited to 'library/c/tvmauth/src/exception.h')
-rw-r--r-- | library/c/tvmauth/src/exception.h | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/library/c/tvmauth/src/exception.h b/library/c/tvmauth/src/exception.h new file mode 100644 index 00000000000..ecda6b3e385 --- /dev/null +++ b/library/c/tvmauth/src/exception.h @@ -0,0 +1,42 @@ +#pragma once + +#include <library/c/tvmauth/tvmauth.h> + +#include <library/cpp/tvmauth/exception.h> +#include <library/cpp/tvmauth/client/exception.h> + +#include <util/generic/yexception.h> + +#include <exception> +#include <string> + +namespace NTvmAuthC { + template <class T> + TA_EErrorCode CatchExceptions(T lambda) { + using namespace NTvmAuth; + + try { + return lambda(); + } catch (const TEmptyTvmKeysException&) { + return TA_EC_EMPTY_TVM_KEYS; + } catch (const TMalformedTvmKeysException&) { + return TA_EC_MALFORMED_TVM_KEYS; + } catch (const TMalformedTvmSecretException&) { + return TA_EC_MALFORMED_TVM_SECRET; + } catch (const TNotAllowedException&) { + return TA_EC_NOT_ALLOWED; + } catch (const TBrokenTvmClientSettings&) { + return TA_EC_BROKEN_TVM_CLIENT_SETTINGS; + } catch (const TPermissionDenied&) { + return TA_EC_PERMISSION_DENIED_TO_CACHE_DIR; + } catch (const TMissingServiceTicket&) { + return TA_EC_UNEXPECTED_ERROR; + } catch (const TNonRetriableException&) { + return TA_EC_FAILED_TO_START_TVM_CLIENT; + } catch (const TRetriableException&) { + return TA_EC_FAILED_TO_START_TVM_CLIENT; + } catch (...) { + return TA_EC_UNEXPECTED_ERROR; + } + } +} |