| eRPC Generator (erpcgen) Rev. 1.8.1 NXP Semiconductors

- Main Page
- Classes
- Files

- File List

ParseErrors.h
1 /*
2 * Copyright (c) 2014, Freescale Semiconductor, Inc.
3 * Copyright 2016 NXP
4 * All rights reserved.
5 *
6 *
7 * SPDX-License-Identifier: BSD-3-Clause
8 */
9
10 #ifndef _EMBEDDED_RPC__PARSEERRORS_H
11 #define _EMBEDDED_RPC__PARSEERRORS_H
12
13 #include "Logging.h"
14 #include "Token.h"
15 #include "os_config.h"
16
17 #include <stdexcept>
18
20 // Definitions
22
23 #define MAX_MESSAGE_SIZE 100
24
26 // Classes
28
29 namespace erpcgen {
30
34 class erpc_error : public std::runtime_error
35 {
36 public:
42 explicit erpc_error(const std::string &__arg)
43 : std::runtime_error(__arg)
44 , m_message(__arg)
45 {
46 }
47
48 protected:
49 std::string m_message;
50 std::string m_errName;
58 explicit erpc_error(const std::string &__arg, std::string errorName)
59 : std::runtime_error(__arg)
60 , m_message(__arg)
61 , m_errName(errorName)
62 {
63 }
64 };
65
69 class syntax_error : public erpc_error
70 {
71 public:
77 explicit syntax_error(const std::string &__arg)
78 : erpc_error(__arg)
79 {
80 }
81 };
82
86 class syntax_error2 : public erpc_error
87 {
88 public:
96 explicit syntax_error2(const std::string &__arg, token_loc_t loc, std::string &fileName)
97 : erpc_error(__arg, "syntax error")
98 , m_errLoc(loc)
99 , m_what(format_string("file %s:%d:%d: %s, %s", fileName.c_str(), m_errLoc.m_firstLine, m_errLoc.m_firstChar,
100 m_errName.c_str(), m_message.c_str()))
101 {
102 }
103
111 explicit syntax_error2(const char *__arg, token_loc_t loc, std::string &fileName)
112 : erpc_error(std::string(__arg), "syntax error")
113 , m_errLoc(loc)
114 , m_what(format_string("file %s:%d:%d: %s, %s", fileName.c_str(), m_errLoc.m_firstLine, m_errLoc.m_firstChar,
115 m_errName.c_str(), m_message.c_str()))
116 {
117 }
118
124 virtual const char *what() const NOEXCEPT NOTHROW;
125
126 private:
127 token_loc_t m_errLoc;
128 std::string m_what;
129 };
130
134 class lexical_error : public erpc_error
135 {
136 public:
142 explicit lexical_error(const std::string &__arg)
143 : erpc_error(__arg)
144 {
145 }
146 };
147
151 class semantic_error : public erpc_error
152 {
153 public:
159 explicit semantic_error(const std::string &__arg)
160 : erpc_error(__arg)
161 {
162 }
163 };
164
168 class internal_error : public erpc_error
169 {
170 public:
176 explicit internal_error(const std::string &__arg)
177 : erpc_error(__arg)
178 {
179 }
180 };
181
185 inline void assert_throw_internal(bool p, const std::string &&msg)
186 {
187 if (!p)
188 {
189 throw internal_error(msg);
190 }
191 }
192
196 template <class T>
197 T *check_null(T *t)
198 {
199 if (t)
200 {
201 return t;
202 }
203 else
204 {
205 throw internal_error("unexpected null object");
206 }
207 }
208
209 } // namespace erpcgen
210
211 #endif // _EMBEDDED_RPC__PARSEERRORS_H
erpcgen::syntax_error
Exception class for syntax errors.
Definition: ParseErrors.h:69
erpcgen::syntax_error2::syntax_error2
syntax_error2(const std::string &__arg, token_loc_t loc, std::string &fileName)
Exception function for syntax errors.
Definition: ParseErrors.h:96
erpcgen::erpc_error::erpc_error
erpc_error(const std::string &__arg)
Exception function for eRPC errors.
Definition: ParseErrors.h:42
erpcgen::internal_error
Exception class for internal errors.
Definition: ParseErrors.h:168
erpcgen::lexical_error::lexical_error
lexical_error(const std::string &__arg)
Exception function for lexical errors.
Definition: ParseErrors.h:142
erpcgen::erpc_error::m_errName
std::string m_errName
Definition: ParseErrors.h:50
erpcgen::semantic_error::semantic_error
semantic_error(const std::string &__arg)
Exception function for semantic errors.
Definition: ParseErrors.h:159
std
STL namespace.
erpcgen::lexical_error
Exception class for lexical errors.
Definition: ParseErrors.h:134
erpcgen::syntax_error2::syntax_error2
syntax_error2(const char *__arg, token_loc_t loc, std::string &fileName)
Exception function for syntax errors.
Definition: ParseErrors.h:111
erpcgen::syntax_error2
Exception class for syntax errors.
Definition: ParseErrors.h:86
erpcgen::erpc_error::erpc_error
erpc_error(const std::string &__arg, std::string errorName)
Exception function for eRPC errors.
Definition: ParseErrors.h:58
erpcgen::syntax_error::syntax_error
syntax_error(const std::string &__arg)
Exception function for syntax errors.
Definition: ParseErrors.h:77
erpcgen::token_loc_t
Token location in the source file.
Definition: Token.h:25
erpcgen::semantic_error
Exception class for semantic errors.
Definition: ParseErrors.h:151
erpcgen::erpc_error::m_message
std::string m_message
Definition: ParseErrors.h:49
erpcgen
Definition: AstNode.h:26
erpcgen::internal_error::internal_error
internal_error(const std::string &__arg)
Exception function for internal errors.
Definition: ParseErrors.h:176
erpcgen::erpc_error
Base exception class for eRPC errors.
Definition: ParseErrors.h:34