generateTextMessage method

  1. @override
String generateTextMessage()

Internal method that generates a complete message about the event

See examples: TalkerLog -> TalkerLog.generateTextMessage TalkerException -> TalkerException.generateTextMessage TalkerError -> TalkerError.generateTextMessage

Implementation

@override
String generateTextMessage() {
  var msg = '[$title] [${dioException.requestOptions.method}] $message';

  final responseMessage = dioException.message;
  final statusCode = dioException.response?.statusCode;
  final data = dioException.response?.data;
  final headers = dioException.requestOptions.headers;

  if (statusCode != null) {
    msg += '\nStatus: ${dioException.response?.statusCode}';
  }
  msg += '\nMessage: $responseMessage';

  if (data != null) {
    final prettyData = encoder.convert(data);
    msg += '\nData: $prettyData';
  }
  if (headers.isNotEmpty) {
    final prettyHeaders = encoder.convert(headers);
    msg += '\nHeaders: $prettyHeaders';
  }
  return msg;
}