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, Inc.
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
24
#include <drizzled/sql_error.h>
30
This class represents the interface for internal error handlers.
31
Internal error handlers are exception handlers used by the server
34
class Internal_error_handler
37
Internal_error_handler() {}
38
virtual ~Internal_error_handler() {}
42
Handle an error condition.
43
This method can be implemented by a subclass to achieve any of the
45
- mask an error internally, prevent exposing it to the user,
46
- mask an error and throw another one instead.
47
When this method returns true, the error condition is considered
48
'handled', and will not be propagated to upper layers.
49
It is the responsability of the code installing an internal handler
50
to then check for trapped conditions, and implement logic to recover
51
from the anticipated conditions trapped during runtime.
53
This mechanism is similar to C++ try/throw/catch:
54
- 'try' correspond to <code>Session::push_internal_handler()</code>,
55
- 'throw' correspond to <code>my_error()</code>,
56
which invokes <code>my_message_sql()</code>,
57
- 'catch' correspond to checking how/if an internal handler was invoked,
58
before removing it from the exception stack with
59
<code>Session::pop_internal_handler()</code>.
61
@param sql_errno the error number
62
@param level the error level
63
@param session the calling thread
64
@return true if the error is handled
66
virtual bool handle_error(drizzled::error_t sql_errno,
68
DRIZZLE_ERROR::enum_warning_level level,
69
Session *session) = 0;
72
} /* namespace drizzled */
74
#endif /* DRIZZLED_INTERNAL_ERROR_HANDLER_H */