2 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
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 #include <native_service/frameworkunified_framework_error.hpp>
20 #include "frameworkunified_framework_error_internal.hpp"
22 // using std::snprintf;
23 typedef std::string TErrorDesc;
24 typedef const TErrorDesc TCErrorDesc;
28 PCSTR FrameworkunifiedStatusDesc(EFrameworkunifiedStatus status) {
30 case eFrameworkunifiedStatusSessionLimitMaxedOut:
31 return "Session limit maxed out";
32 case eFrameworkunifiedStatusDbRecNotFound:
33 return "Db record not Found";
34 case eFrameworkunifiedStatusDbResultError:
35 return "Db result error";
36 case eFrameworkunifiedStatusDbExecuteFail:
37 return "Db execute failure";
38 case eFrameworkunifiedStatusSemCloseFail:
39 return "Semaphore close failure";
40 case eFrameworkunifiedStatusSemUnlockFail:
41 return "Semaphore unlock gailure";
42 case eFrameworkunifiedStatusSemLockFail:
43 return "Semaphore lock failure";
44 case eFrameworkunifiedStatusFail:
46 case eFrameworkunifiedStatusOK:
48 case eFrameworkunifiedStatusInvldBuf:
49 return "Invalid buffer";
50 case eFrameworkunifiedStatusInvldHandle:
51 return "Invalid handle";
52 case eFrameworkunifiedStatusInvldHndlType:
53 return "Invalid handle yype";
54 case eFrameworkunifiedStatusInvldQName:
55 return "Invalid queue name";
56 case eFrameworkunifiedStatusMsgQFull:
57 return "Message queue full";
58 case eFrameworkunifiedStatusInvldNotification:
59 return "Invliad notification";
60 case eFrameworkunifiedStatusInvldParam:
61 return "Invalid parameter";
62 case eFrameworkunifiedStatusInvldBufSize:
63 return "Invalid buffer size";
64 case eFrameworkunifiedStatusInvldID:
65 return "Invalid MemID";
66 case eFrameworkunifiedStatusCannotRelease:
67 return "Cannot release resource";
68 case eFrameworkunifiedStatusBadConnection:
69 return "Bad connection";
70 case eFrameworkunifiedStatusExit:
72 case eFrameworkunifiedStatusNotImplemented:
73 return "Not implemented";
74 case eFrameworkunifiedStatusThreadBusy:
76 case eFrameworkunifiedStatusThreadSelfJoin:
77 return "Attempted to self-join";
78 case eFrameworkunifiedStatusThreadInvalidVal:
79 return "Invalid value passed";
80 case eFrameworkunifiedStatusThreadNotExist:
81 return "Thread does not exist";
82 case eFrameworkunifiedStatusFault:
84 case eFrameworkunifiedStatusServNotFound:
85 return "Service not found";
86 case eFrameworkunifiedStatusErrOther:
92 TCErrorDesc BuildFrameworkunifiedErrorDesc(EFrameworkunifiedStatus error, PCSTR errorMsg) {
93 CHAR buf[ MAX_QUEUE_MSG_SIZE ] = {};
96 "Framework Error: %s - %s",
97 FrameworkunifiedStatusDesc(error),
98 errorMsg != 0 ? errorMsg : NULL);
99 return TErrorDesc(&buf[ 0 ]);
102 TCErrorDesc BuildFrameworkunifiedSystemErrorDesc(EFrameworkunifiedSystemError error, PCSTR errorMsg) {
103 TErrorDesc l_cErrorMsg("Framework defined error desc: ");
106 // Commented, because this is product specific error. Must handle by SystemServices only.
107 // case eFrameworkunifiedDSPHardwareReset : l_cErrorMsg.append("DSP HW RESET ERROR"); break;
109 l_cErrorMsg.append("Other error");
113 l_cErrorMsg.append(" :: Application provided error desc:");
114 l_cErrorMsg.append(errorMsg);
122 frameworkunified::framework::error::error::error(EFrameworkunifiedStatus error, PCSTR errorMsg)
123 : std::runtime_error(BuildFrameworkunifiedErrorDesc(error, errorMsg)),
127 frameworkunified::framework::error::CSystemError::CSystemError(EFrameworkunifiedSystemError error, PCSTR errorMsg)
128 : std::runtime_error(BuildFrameworkunifiedSystemErrorDesc(error, errorMsg)),
129 m_eSystemError(error) {