From 401f59efe466d7bc55174666a598d49941bc3ff8 Mon Sep 17 00:00:00 2001 From: Zofia Abramowska Date: Tue, 7 Oct 2014 14:46:47 +0200 Subject: [PATCH] Add PluginErrorException Add exception class for plugin processing error. Change-Id: I26090bd3a54bdbc4767fd05735b5b06fae523b2f --- src/common/exceptions/PluginErrorException.h | 48 ++++++++++++++++++++++++++++ src/service/logic/Logic.cpp | 7 ++-- 2 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 src/common/exceptions/PluginErrorException.h diff --git a/src/common/exceptions/PluginErrorException.h b/src/common/exceptions/PluginErrorException.h new file mode 100644 index 0000000..a29eab5 --- /dev/null +++ b/src/common/exceptions/PluginErrorException.h @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @file src/common/exceptions/PluginErrorException.h + * @author Zofia Abramowska + * @version 1.0 + * @brief Implementation of PluginErrorException + */ +#ifndef SRC_COMMON_EXCEPTIONS_PLUGINERROREXCEPTION_H_ +#define SRC_COMMON_EXCEPTIONS_PLUGINERROREXCEPTION_H_ + +#include +#include + +namespace Cynara { + +class PluginErrorException : public Exception { +public: + PluginErrorException(const PolicyKey &key) { + m_message = "Plugin couldn't get result for user <" + key.user().toString() + ">, " + "client <" + key.client().toString() + ">, " + "privilege <" + key.privilege().toString() + ">"; + } + + const std::string message(void) const { + return m_message; + } + +private: + std::string m_message; +}; + +} // namespace Cynara + +#endif // SRC_COMMON_EXCEPTIONS_PLUGINERROREXCEPTION_H_ diff --git a/src/service/logic/Logic.cpp b/src/service/logic/Logic.cpp index 60a0cce..1787575 100644 --- a/src/service/logic/Logic.cpp +++ b/src/service/logic/Logic.cpp @@ -22,10 +22,12 @@ #include #include -#include #include #include #include +#include +#include + #include #include
@@ -117,8 +119,7 @@ bool Logic::check(RequestContextPtr context UNUSED, const PolicyKey &key, //context should be saved in plugin in order to return answer when ready return false; default: - //todo make additional class - throw std::runtime_error("Plugin error"); + throw PluginErrorException(key); } } -- 2.7.4