drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
plugin/json_server/error.h
1 /* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3 *
4 * Copyright (C) 2011-2013 Stewart Smith, Henrik Ingo, Mohit Srivastava
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; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
23#include <config.h>
24
25#include <drizzled/error_t.h>
26#include <string>
27namespace drizzle_plugin
28{
29namespace json_server
30{
36 {
37 public:
42 {
43 ER_EMPTY=0,
44 ER_SQL,
45 ER_JSON,
46 ER_HTTP,
47 ER_UNKNOWN
48 };
49
60 void set_error(enum_error_type type,drizzled::error_t sql_errno_arg,const char *message_arg);
67 bool is_error(){return er_type!= ER_EMPTY;}
74 bool is_sqlerror(){return er_type == ER_SQL;}
81 bool is_jsonerror(){return er_type == ER_JSON;}
88 bool is_httperror(){return er_type == ER_HTTP;}
95 bool is_unknownerror(){return er_type == ER_UNKNOWN;}
101 drizzled::error_t get_error_no() const { return error_no;}
107 const char* get_error_msg() const { return error_msg;}
113 const char* get_sql_state() const { return sql_state;}
125 std::string get_error_type_string() const {
126 std::string error_str;
127 switch(er_type)
128 {
129 case ER_EMPTY: {error_str="NO ERROR"; break;}
130 case ER_SQL: {error_str="SQL ERROR"; break;}
131 case ER_JSON: {error_str="JSON ERROR"; break;}
132 case ER_HTTP: {error_str="HTTP ERROR"; break;}
133 case ER_UNKNOWN: {error_str="UNKNOWN ERROR"; break;}
134 }
135 return error_str;
136 }
137
138 private:
146 drizzled::error_t error_no;
150 const char *error_msg;
154 const char *sql_state;
155
156 };
157}
158}
void set_error(enum_error_type type, drizzled::error_t sql_errno_arg, const char *message_arg)
Convert from decimal to binary representation.
Definition common_fwd.h:215