SDL_GetError returns an empty string, not nil, when there are no errors.
@@ -23,7 +23,11 @@ func (ec ErrorCode) c() C.SDL_errorcode {
// GetError (https://wiki.libsdl.org/SDL_GetError)
func GetError() error {
if err := C.SDL_GetError(); err != nil {
- return errors.New(C.GoString(err))
+ gostr := C.GoString(err)
+ // SDL_GetError returns "an empty string if there hasn't been an error message"
+ if len(gostr) > 0 {
+ return errors.New(gostr)
+ }
}
return nil
}
