diff options
author | Andy <drumsetmonkey@gmail.com> | 2019-08-29 13:07:45 -0400 |
---|---|---|
committer | Andy <drumsetmonkey@gmail.com> | 2019-08-29 13:07:45 -0400 |
commit | 4ac4b280abf2ffa28caa5a532353115a3033444f (patch) | |
tree | 2a13d658bb454360b2faf401244bb0321d3460d4 /lib/sol2/docs/source/api/error.rst | |
parent | e9758416b18b27a65337c28d9641afc0ee89b34b (diff) | |
parent | 7a46fa2dd3dad3f038bf8e7339bc67abca428ae6 (diff) |
Started creating scripting library/namespace and added sol2 for interfacing
Diffstat (limited to 'lib/sol2/docs/source/api/error.rst')
-rw-r--r-- | lib/sol2/docs/source/api/error.rst | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/sol2/docs/source/api/error.rst b/lib/sol2/docs/source/api/error.rst new file mode 100644 index 0000000..0548648 --- /dev/null +++ b/lib/sol2/docs/source/api/error.rst @@ -0,0 +1,21 @@ +error +===== +*the single error/exception type* + + +.. code-block:: cpp + + class error : public std::runtime_error { + public: + error(const std::string& str): std::runtime_error("lua: error: " + str) {} + }; + + +.. note:: + + Please do not throw this error type yourself. It belongs to the library and we do some information appending at the front. + + +If an eror is thrown by sol, it is going to be of this type. We use this in a single place: the default ``at_panic`` function we bind on construction of a :ref:`sol::state<set-panic>`. If you turn :doc:`off exceptions<../exceptions>`, the chances of you seeing this error are nil unless you specifically use it to pull errors out of things such as :doc:`sol::protected_function<protected_function>`. + +As it derives from ``std::runtime_error``, which derives from ``std::exception``, you can catch it with a ``catch (const std::exception& )`` clause in your try/catch blocks. You can retrieve a string error from Lua (Lua pushes all its errors as string returns) by using this type with any of the get or lookup functions in sol. |