ApiError.fromStatus constructor
Create from HTTP status code.
Implementation
factory ApiError.fromStatus(int statusCode, {String? body}) {
final parsed = body != null ? _tryParseJson(body) : null;
final msg =
parsed?['error']?['message'] as String? ?? _defaultMessage(statusCode);
return ApiError(
message: msg,
errorId: 'api_$statusCode',
statusCode: statusCode,
errorType: parsed?['error']?['type'] as String?,
responseBody: parsed,
suggestion: _suggestion(statusCode),
);
}