851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
1 |
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
|
2 |
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
|
|
3 |
*
|
|
4 |
* Copyright (C) 2008 Sun Microsystems
|
|
5 |
*
|
|
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.
|
|
9 |
*
|
|
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.
|
|
14 |
*
|
|
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
|
|
18 |
*/
|
|
19 |
||
20 |
||
21 |
#ifndef DRIZZLED_INTERNAL_ERROR_HANDLER_H
|
|
22 |
#define DRIZZLED_INTERNAL_ERROR_HANDLER_H
|
|
23 |
||
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
24 |
namespace drizzled |
25 |
{
|
|
851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
26 |
|
27 |
/**
|
|
28 |
This class represents the interface for internal error handlers.
|
|
29 |
Internal error handlers are exception handlers used by the server
|
|
30 |
implementation.
|
|
31 |
*/
|
|
32 |
class Internal_error_handler |
|
33 |
{
|
|
34 |
protected: |
|
35 |
Internal_error_handler() {} |
|
36 |
virtual ~Internal_error_handler() {} |
|
37 |
||
38 |
public: |
|
39 |
/**
|
|
40 |
Handle an error condition.
|
|
41 |
This method can be implemented by a subclass to achieve any of the
|
|
42 |
following:
|
|
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.
|
|
50 |
||
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>.
|
|
58 |
||
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
|
|
63 |
*/
|
|
64 |
virtual bool handle_error(uint32_t sql_errno, |
|
65 |
const char *message, |
|
66 |
DRIZZLE_ERROR::enum_warning_level level, |
|
67 |
Session *session) = 0; |
|
68 |
};
|
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
69 |
|
70 |
} /* namespace drizzled */ |
|
71 |
||
851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
72 |
#endif /* DRIZZLED_INTERNAL_ERROR_HANDLER_H */ |