diff options
author | David Robillard <d@drobilla.net> | 2019-11-03 21:13:40 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2019-11-09 12:15:17 +0100 |
commit | b5f04656a4b3d1b43a66585ead8ef55536a4fdbc (patch) | |
tree | efc8765b6e7a5c670735205593a7daed38bce83b /pugl/detail | |
parent | be838db18af13390cb9f705d36ab83396d2dd1e6 (diff) | |
download | pugl-b5f04656a4b3d1b43a66585ead8ef55536a4fdbc.tar.gz pugl-b5f04656a4b3d1b43a66585ead8ef55536a4fdbc.tar.bz2 pugl-b5f04656a4b3d1b43a66585ead8ef55536a4fdbc.zip |
Add puglStrerror() and improve test program error reporting
Diffstat (limited to 'pugl/detail')
-rw-r--r-- | pugl/detail/implementation.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/pugl/detail/implementation.c b/pugl/detail/implementation.c index 80a7a32..a2ff2ec 100644 --- a/pugl/detail/implementation.c +++ b/pugl/detail/implementation.c @@ -25,6 +25,25 @@ #include <stdlib.h> #include <string.h> +const char* +puglStrerror(const PuglStatus status) +{ + switch (status) { + case PUGL_SUCCESS: return "Success"; + case PUGL_FAILURE: return "Non-fatal failure"; + case PUGL_UNKNOWN_ERROR: return "Unknown system error"; + case PUGL_BAD_BACKEND: return "Invalid or missing backend"; + case PUGL_BACKEND_FAILED: return "Backend initialisation failed"; + case PUGL_REGISTRATION_FAILED: return "Window class registration failed"; + case PUGL_CREATE_WINDOW_FAILED: return "Window creation failed"; + case PUGL_SET_FORMAT_FAILED: return "Failed to set pixel format"; + case PUGL_CREATE_CONTEXT_FAILED: return "Failed to create drawing context"; + case PUGL_UNSUPPORTED_TYPE: return "Unsupported data type"; + } + + return "Unknown error"; +} + void puglSetString(char** dest, const char* string) { |