Answer: it depends on your code limitations.
collectd prints a standard error, then takes over if it hits a fatal error.
OpenGL will set some general state that you can request. Ignoring this error often leads to undefined behavior.
Collectd has a lot of threading issues, and most errors cannot be fixed or repaired by the program. For example, if a plugin depends on a library, and calling this library fails, the plugin knows more about how to recover this error. Bubbling that a bug up is not useful since core core will never know about the N + 1 plugin
On the other hand, OpenGL applications are usually responsible for any errors that occur and may try to fix the errors. For example, if they try to compile a shader, but may have special ones for a specific vendor or platform.
Depending on the design of your program, consider the following:
- Will you be wrong so you can make a better decision?
- Does the caller know about your implementation? Do they have to?
- Are errors fixed by your application possible?
- eg. If you cannot open the socket or file, you can try again or fail, and not much more.
- Are there any restrictions around the global state if you execute the
GetLastError() function?
Update:
A transition with a global state parameter may have the following:
#include <stdlib.h>
Running the above program
$ ./a.out -1 2 -4 0 -6 4 We can't take the square root of a negative number the square root of 2 is: 1 We can't take the square root of a negative number the square root of 0 is: 0 We can't take the square root of a negative number the square root of 4 is: 2
source share