better API error reporting