Initial revision
[luabind.git] / luabind / detail / error.hpp
blobc0e0eac22d15cf82fb6c648183c987cb0beee7ad
1 // Copyright (c) 2003 Daniel Wallin and Arvid Norberg
3 // Permission is hereby granted, free of charge, to any person obtaining a
4 // copy of this software and associated documentation files (the "Software"),
5 // to deal in the Software without restriction, including without limitation
6 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 // and/or sell copies of the Software, and to permit persons to whom the
8 // Software is furnished to do so, subject to the following conditions:
10 // The above copyright notice and this permission notice shall be included
11 // in all copies or substantial portions of the Software.
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
14 // ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
15 // TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
16 // PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
17 // SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
18 // ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
21 // OR OTHER DEALINGS IN THE SOFTWARE.
23 #ifndef LUABIND_ERROR_HPP_INCLUDED
24 #define LUABIND_ERROR_HPP_INCLUDED
26 #include <exception>
28 namespace luabind
30 // this exception usually means that the lua function you called
31 // from C++ failed with an error code. You will have to
32 // read the error code from the top of the lua stack
33 // the reason why this exception class doesn't contain
34 // the message itself is that std::string's copy constructor
35 // may throw, if the copy constructor of an exception that is
36 // being thrown throws another exception, terminate will be called
37 // and the entire application is killed.
38 struct error : public std::exception
40 virtual const char* what() const throw()
42 return "lua runtime error";
46 // this exception is thrown when you call a lua function
47 // from C++, and the return value on the lua stack cannot
48 // be converted to the type you specified in the C++ call
49 // (as a template parameter)
50 class cant_convert_return_value: public std::exception
52 public:
54 virtual const char* what() const throw()
56 return "The return value from the called function cannot be converted by the given return value policy";
61 // if a object_cast<>() fails, this is thrown
62 class cast_failed : public std::exception
64 public:
65 virtual const char* what() const throw() { return "unable to make cast"; }
71 #endif // LUABIND_ERROR_HPP_INCLUDED