2 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef EXCEPTION_INTERNAL_H_
18 #define EXCEPTION_INTERNAL_H_
23 #include "log-private.h"
25 #define THROW(error_code) throw Exception(error_code)
27 namespace tizen_base {
30 class Exception : public std::exception {
32 explicit Exception(int error_code, std::string file = __FILE__,
33 int line = __LINE__ ) {
34 error_code_ = error_code;
35 message_ = file.substr(file.find_last_of("/") + 1) + ":"
36 + std::to_string(line) + " code:" + std::to_string(error_code_);
39 virtual ~Exception() {}
41 virtual const char *what(void) const noexcept {
42 return message_.c_str();
45 int GetErrorCode() const {
54 } // namespace internal
55 } // namespace tizen_base
57 #endif // EXCEPTION_INTERNAL_H_