1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 2 of the License.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
#ifndef DRIZZLED_INTERNAL_ERROR_HANDLER_H
22
#define DRIZZLED_INTERNAL_ERROR_HANDLER_H
28
This class represents the interface for internal error handlers.
29
Internal error handlers are exception handlers used by the server
32
class Internal_error_handler
35
Internal_error_handler() {}
36
virtual ~Internal_error_handler() {}
40
Handle an error condition.
41
This method can be implemented by a subclass to achieve any of the
43
- mask an error internally, prevent exposing it to the user,
44
- mask an error and throw another one instead.
45
When this method returns true, the error condition is considered
46
'handled', and will not be propagated to upper layers.
47
It is the responsability of the code installing an internal handler
48
to then check for trapped conditions, and implement logic to recover
49
from the anticipated conditions trapped during runtime.
51
This mechanism is similar to C++ try/throw/catch:
52
- 'try' correspond to <code>Session::push_internal_handler()</code>,
53
- 'throw' correspond to <code>my_error()</code>,
54
which invokes <code>my_message_sql()</code>,
55
- 'catch' correspond to checking how/if an internal handler was invoked,
56
before removing it from the exception stack with
57
<code>Session::pop_internal_handler()</code>.
59
@param sql_errno the error number
60
@param level the error level
61
@param session the calling thread
62
@return true if the error is handled
64
virtual bool handle_error(uint32_t sql_errno,
66
DRIZZLE_ERROR::enum_warning_level level,
67
Session *session) = 0;
70
} /* namespace drizzled */
72
#endif /* DRIZZLED_INTERNAL_ERROR_HANDLER_H */