MySQL  8.0.21
Source Code Documentation
sql_exception_handler.h
Go to the documentation of this file.
1 #ifndef SQL_EXCEPTION_HANDLER_H_INCLUDED
2 #define SQL_EXCEPTION_HANDLER_H_INCLUDED
3 
4 /*
5  Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License, version 2.0,
9  as published by the Free Software Foundation.
10 
11  This program is also distributed with certain software (including
12  but not limited to OpenSSL) that is licensed under separate terms,
13  as designated in a particular file or component or in included license
14  documentation. The authors of MySQL hereby grant you an additional
15  permission to link the program and your derivative works with the
16  separately licensed software that they have included with MySQL.
17 
18  This program is distributed in the hope that it will be useful,
19  but WITHOUT ANY WARRANTY; without even the implied warranty of
20  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  GNU General Public License, version 2.0, for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with this program; if not, write to the Free Software
25  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 */
27 
28 /**
29  @file
30 
31  @brief This file declares functions to convert exceptions to MySQL
32  error messages.
33 
34  The pattern for use in other functions is:
35 
36  @code
37  try
38  {
39  something_that_throws();
40  }
41  catch (...)
42  {
43  handle_foo_exception("function_name");
44  }
45  @endcode
46 
47  There are different handlers for different use cases.
48 */
49 
50 /**
51  Handle an exception of any type.
52 
53  Code that could throw exceptions should be wrapped in try/catch, and
54  the catch block should raise a corresponding MySQL error. If this
55  function is called from the catch block, it will raise a specialized
56  error message for many of the std::exception subclasses, or a more
57  generic error message if it is not a std::exception.
58 
59  @param funcname the name of the function that caught an exception
60 
61  @see handle_gis_exception
62 */
63 void handle_std_exception(const char *funcname);
64 
65 /**
66  Handle a GIS exception of any type.
67 
68  This function constitutes the exception handling barrier between
69  Boost.Geometry and MySQL code. It handles all exceptions thrown in
70  GIS code and raises the corresponding error in MySQL.
71 
72  Pattern for use in other functions:
73 
74  @code
75  try
76  {
77  something_that_throws();
78  }
79  catch (...)
80  {
81  handle_gis_exception("st_foo");
82  }
83  @endcode
84 
85  Other exception handling code put into the catch block, before or
86  after the call to handle_gis_exception(), must not throw exceptions.
87 
88  @param funcname Function name for use in error message
89 
90  @see handle_std_exception
91  */
92 void handle_gis_exception(const char *funcname);
93 
94 #endif // SQL_EXCEPTION_HANDLER_H_INCLUDED
void handle_std_exception(const char *funcname)
Handle an exception of any type.
Definition: sql_exception_handler.cc:58
void handle_gis_exception(const char *funcname)
Handle a GIS exception of any type.
Definition: sql_exception_handler.cc:90