CUBRID Engine
latest
Main Page
Namespaces
Classes
Files
File List
File Members
error_context.hpp
Go to the documentation of this file.
1
/*
2
* Copyright 2008 Search Solution Corporation
3
* Copyright 2016 CUBRID Corporation
4
*
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at
8
*
9
* http://www.apache.org/licenses/LICENSE-2.0
10
*
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
16
*
17
*/
18
19
/*
20
* error_context.hpp - interface for error context
21
*/
22
23
#ifndef _ERROR_CONTEXT_HPP_
24
#define _ERROR_CONTEXT_HPP_
25
26
#include <cstddef>
27
28
#include <stack>
29
30
namespace
cuberr
31
{
32
const
std::size_t
ER_EMERGENCY_BUF_SIZE
= 256;
33
34
// legacy structures
35
union
er_va_arg
36
{
37
int
int_value
;
/* holders for the values that we actually */
38
void
*
pointer_value
;
/* retrieve from the va_list. */
39
double
double_value
;
40
long
double
longdouble_value
;
41
const
char
*
string_value
;
42
long
long
longlong_value
;
43
};
44
45
struct
er_message
46
{
47
public
:
48
er_message
(
const
bool
&logging);
49
~
er_message
();
50
51
void
swap (
er_message
&other);
52
53
void
clear_error (
void
);
// clear error and message
54
void
set_error (
int
error_id,
int
error_severity,
const
char
*filename,
int
line_no);
// set error
55
void
reserve_message_area (std::size_t size);
56
void
clear_message_area (
void
);
57
void
clear_args (
void
);
58
59
int
err_id
;
/* Error identifier of the current message */
60
int
severity
;
/* Warning, Error, FATAL Error, etc... */
61
const
char
*
file_name
;
/* File where the error is set */
62
int
line_no
;
/* Line in the file where the error is set */
63
std::size_t
msg_area_size
;
/* Size of the message area */
64
char
*
msg_area
;
/* Pointer to message area */
65
er_va_arg
*
args
;
/* Array of va_list entries */
66
int
nargs
;
/* Length of array */
67
char
msg_buffer[
ER_EMERGENCY_BUF_SIZE
];
// message buffer
68
69
private
:
70
// not copy constructible
71
er_message
(
er_message
&);
72
73
const
bool
&
m_logging
;
// reference to context logging
74
};
75
76
class
context
77
{
78
public
:
79
80
// constructor
81
// automatic_registration - if true, registration/deregistration is handled during construct/destruct
82
// logging - if true, extensive logging is activated.
83
// NOTE: "nested" logging is possible and er_Log_file_mutex may be locked twice causing a hang.
84
// fix this if you want to use the error context logging.
85
//
86
context
(
bool
automatic_registration =
false
,
bool
logging =
false
);
87
88
~
context
();
89
90
er_message
&get_current_error_level (
void
);
91
92
void
register_thread_local (
void
);
93
void
deregister_thread_local (
void
);
94
95
void
clear_current_error_level (
void
);
96
void
push_error_stack (
void
);
97
void
pop_error_stack (
er_message
&popped);
// caller will destroy popped
98
void
pop_error_stack_and_destroy (
void
);
99
bool
has_error_stack (
void
);
100
101
const
bool
&get_logging (
void
);
102
103
static
context
&get_thread_local_context (
void
);
104
static
er_message
&get_thread_local_error (
void
);
105
106
private
:
107
void
clear_all_levels (
void
);
108
void
clear_stack (
void
);
109
110
er_message
m_base_level
;
111
std::stack<er_message>
m_stack
;
112
bool
m_automatic_registration
;
113
bool
m_logging
;
// activate logging
114
bool
m_destroyed
;
// set to true on destruction
115
};
116
}
// namespace cuberr
117
118
#endif // _ERROR_CONTEXT_HPP_
cuberr::er_message::args
er_va_arg * args
Definition:
error_context.hpp:65
cuberr::er_va_arg::longlong_value
long long longlong_value
Definition:
error_context.hpp:42
cuberr::er_va_arg::string_value
const char * string_value
Definition:
error_context.hpp:41
cuberr::context::m_destroyed
bool m_destroyed
Definition:
error_context.hpp:114
cuberr::context::m_automatic_registration
bool m_automatic_registration
Definition:
error_context.hpp:112
cuberr::er_message::msg_area
char * msg_area
Definition:
error_context.hpp:64
cuberr::er_va_arg::int_value
int int_value
Definition:
error_context.hpp:37
cuberr::context::m_base_level
er_message m_base_level
Definition:
error_context.hpp:110
cuberr::er_message::err_id
int err_id
Definition:
error_context.hpp:59
cuberr::er_va_arg
Definition:
error_context.hpp:35
cuberr::er_va_arg::longdouble_value
long double longdouble_value
Definition:
error_context.hpp:40
cuberr::context::m_stack
std::stack< er_message > m_stack
Definition:
error_context.hpp:111
cuberr::er_message::m_logging
const bool & m_logging
Definition:
error_context.hpp:73
cuberr
Definition:
error_context.cpp:35
cuberr::er_message::nargs
int nargs
Definition:
error_context.hpp:66
cuberr::context
Definition:
error_context.hpp:76
cuberr::er_va_arg::pointer_value
void * pointer_value
Definition:
error_context.hpp:38
cuberr::er_message::line_no
int line_no
Definition:
error_context.hpp:62
cuberr::ER_EMERGENCY_BUF_SIZE
const std::size_t ER_EMERGENCY_BUF_SIZE
Definition:
error_context.hpp:32
cuberr::context::m_logging
bool m_logging
Definition:
error_context.hpp:113
cuberr::er_message
Definition:
error_context.hpp:45
cuberr::er_message::file_name
const char * file_name
Definition:
error_context.hpp:61
cuberr::er_message::severity
int severity
Definition:
error_context.hpp:60
cuberr::er_va_arg::double_value
double double_value
Definition:
error_context.hpp:39
cuberr::er_message::msg_area_size
std::size_t msg_area_size
Definition:
error_context.hpp:63
src
base
error_context.hpp
Generated by
1.8.11