MySQL 8.4.0
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, 2024, Oracle and/or its affiliates.
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 designed to work 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 either included with
17 the program or referenced in the documentation.
18
19 This program is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License, version 2.0, for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with this program; if not, write to the Free Software
26 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27*/
28
29/**
30 @file
31
32 @brief This file declares functions to convert exceptions to MySQL
33 error messages.
34
35 The pattern for use in other functions is:
36
37 @code
38 try
39 {
40 something_that_throws();
41 }
42 catch (...)
43 {
44 handle_foo_exception("function_name");
45 }
46 @endcode
47
48 There are different handlers for different use cases.
49*/
50
51/**
52 Handle an exception of any type.
53
54 Code that could throw exceptions should be wrapped in try/catch, and
55 the catch block should raise a corresponding MySQL error. If this
56 function is called from the catch block, it will raise a specialized
57 error message for many of the std::exception subclasses, or a more
58 generic error message if it is not a std::exception.
59
60 @param funcname the name of the function that caught an exception
61
62 @see handle_gis_exception
63*/
64void handle_std_exception(const char *funcname);
65
66/**
67 Handle a GIS exception of any type.
68
69 This function constitutes the exception handling barrier between
70 Boost.Geometry and MySQL code. It handles all exceptions thrown in
71 GIS code and raises the corresponding error in MySQL.
72
73 Pattern for use in other functions:
74
75 @code
76 try
77 {
78 something_that_throws();
79 }
80 catch (...)
81 {
82 handle_gis_exception("st_foo");
83 }
84 @endcode
85
86 Other exception handling code put into the catch block, before or
87 after the call to handle_gis_exception(), must not throw exceptions.
88
89 @param funcname Function name for use in error message
90
91 @see handle_std_exception
92 */
93void handle_gis_exception(const char *funcname);
94
95#endif // SQL_EXCEPTION_HANDLER_H_INCLUDED
void handle_gis_exception(const char *funcname)
Handle a GIS exception of any type.
Definition: sql_exception_handler.cc:92
void handle_std_exception(const char *funcname)
Handle an exception of any type.
Definition: sql_exception_handler.cc:60