toString method

  1. @override
String toString()
override

Converts the HttpException to a String representation.

This method returns a string that includes the HTTP status code, the error message, and optionally, the related URI and any additional HTTP data, making it useful for logging or debugging purposes.

Implementation

@override
String toString() {
  final StringBuffer stringBuffer = StringBuffer()
    ..write('HttpException ')
    ..write('[')
    ..write('${httpStatus.code} ')
    ..write(httpStatus.name)
    ..write(']')
    ..write(detail != '' ? ': ${detail.trim()}' : '');

  if (uri != null) {
    stringBuffer.write(', uri = $uri');
  }
  if (data != null) {
    stringBuffer.write(', HTTP data = $data');
  }

  return stringBuffer.toString();
}