toString method

  1. @override
String toString()
override

The failure, without the response body.

This used to be prefix + message, where message was the body verbatim. Since an API is free to echo a rejected request back, and since logging a caught exception is the most ordinary thing an application does, that put submitted passwords into crash reports - through the very catch (err) { log('$err'); } pattern the README recommends. The body is still available on body for callers that decide they need it.

Implementation

@override
String toString() {
  return '$prefix${code ?? (status == null ? 'request failed' : 'HTTP $status')}';
}