You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
C++ has an Error Handling facility. This includes error categories by means of which collisions between equal integer error values can be avoided.
This means that in C++ one should use std::error_code instead of int.
I propose to allow for the user to set a call back for errors that passes a std::error_code instead of an int.
Currently it is not possible to set an error call back other than overriding what glfwpp has set (in which case
you get an int, of course; and lose the advantage of the wisdom in the current builtin errorCallback).
Aka - the user calls libary.set_error_callback([](std::error_code code, std::string what){ ... }) and is called back for runtime errors (we can leave in the asserts, although not everyone might want to use an assert :/).
I implement this for every C library that I use, it is very nice to have general error codes.
I already implemented this for glfwpp too, see my gui_ErrorCodes.cxx.
So, if you think it is a good idea I can integrate it into glfwpp for you and do a pull request.
PS The THROW_ALERTC in that code throws an exception that automatically converts the enum to a std::error_code,
when caught and printed, I get - for example -:
WARNING : AIAlert:
glfw3::error_callback(65546, "Cannot make current with a window that has no OpenGL or OpenGL ES context"):
The specified window has no context (GLFW_NO_WINDOW_CONTEXT), caught in HelloTriangleVulkanApplication.cxx.
The text was updated successfully, but these errors were encountered:
C++ has an Error Handling facility. This includes error categories by means of which collisions between equal integer error values can be avoided.
This means that in C++ one should use
std::error_code
instead ofint
.I propose to allow for the user to set a call back for errors that passes a
std::error_code
instead of anint
.Currently it is not possible to set an error call back other than overriding what glfwpp has set (in which case
you get an int, of course; and lose the advantage of the wisdom in the current builtin errorCallback).
Aka - the user calls
libary.set_error_callback([](std::error_code code, std::string what){ ... })
and is called back for runtime errors (we can leave in the asserts, although not everyone might want to use an assert :/).I implement this for every C library that I use, it is very nice to have general error codes.
I already implemented this for glfwpp too, see my gui_ErrorCodes.cxx.
So, if you think it is a good idea I can integrate it into glfwpp for you and do a pull request.
PS The THROW_ALERTC in that code throws an exception that automatically converts the enum to a std::error_code,
when caught and printed, I get - for example -:
The text was updated successfully, but these errors were encountered: