~drizzle-trunk/drizzle/development

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
 *
1999.6.1 by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
851 by Brian Aker
Class rewrite of Session (aka get all of the junk out)
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
2234 by Brian Aker
Mass removal of ifdef/endif in favor of pragma once.
21
#pragma once
851 by Brian Aker
Class rewrite of Session (aka get all of the junk out)
22
2148.7.14 by Brian Aker
Merge in sort of session.
23
#include <drizzled/sql_error.h>
24
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
25
namespace drizzled
26
{
851 by Brian Aker
Class rewrite of Session (aka get all of the junk out)
27
28
/**
29
  This class represents the interface for internal error handlers.
30
  Internal error handlers are exception handlers used by the server
31
  implementation.
32
*/
33
class Internal_error_handler
34
{
35
protected:
36
  Internal_error_handler() {}
37
  virtual ~Internal_error_handler() {}
38
39
public:
40
  /**
41
    Handle an error condition.
42
    This method can be implemented by a subclass to achieve any of the
43
    following:
44
    - mask an error internally, prevent exposing it to the user,
45
    - mask an error and throw another one instead.
46
    When this method returns true, the error condition is considered
47
    'handled', and will not be propagated to upper layers.
48
    It is the responsability of the code installing an internal handler
49
    to then check for trapped conditions, and implement logic to recover
50
    from the anticipated conditions trapped during runtime.
51
52
    This mechanism is similar to C++ try/throw/catch:
53
    - 'try' correspond to <code>Session::push_internal_handler()</code>,
54
    - 'throw' correspond to <code>my_error()</code>,
55
    which invokes <code>my_message_sql()</code>,
56
    - 'catch' correspond to checking how/if an internal handler was invoked,
57
    before removing it from the exception stack with
58
    <code>Session::pop_internal_handler()</code>.
59
60
    @param sql_errno the error number
61
    @param level the error level
62
    @param session the calling thread
63
    @return true if the error is handled
64
  */
2087.3.1 by Brian Aker
Entire convert over to time_t.
65
  virtual bool handle_error(drizzled::error_t sql_errno,
851 by Brian Aker
Class rewrite of Session (aka get all of the junk out)
66
                            const char *message,
67
                            DRIZZLE_ERROR::enum_warning_level level,
68
                            Session *session) = 0;
69
};
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
70
71
} /* namespace drizzled */
72