     @inline(__always)
     func sdlThrow() throws -> Wrapped {
         
-        guard let value = self
-            else { throw SDLError(description: SDLError.errorDescription ?? "") }
-        
+        guard let value = self else {
+            guard let error = SDLError.current else {
+                assertionFailure("No error for nil value \(Wrapped.self)")
+                throw SDLError(description: "")
+            }
+            throw error
+        }
         return value
     }
 }

internal extension SDLError {
    
    /// Text for last reported error.
    static var errorDescription: String? {
        
        guard let cString = SDL_GetError()
            else { return nil }
        
        return String(cString: cString)
    }
}

internal extension CInt {
    
    /// Throws for negative error codes
    @inline(__always)
    func sdlThrow() throws {
        
        guard self >= 0
            else { throw SDLError(description: SDLError.errorDescription ?? "") }
    }
}


import CSDL2

/// SDL Error
public struct SDLError: CustomStringConvertible, Error {
    
    public let description: String
}
