generateTextMessage method

  1. @override
String generateTextMessage({
  1. TimeFormat timeFormat = TimeFormat.timeAndSeconds,
})

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({
  TimeFormat timeFormat = TimeFormat.timeAndSeconds,
}) {
  var msg = '[$title] [${dioException.requestOptions.method}] $message';

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

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

  if (settings.printErrorMessage && responseMessage != null) {
    msg += '\nMessage: $responseMessage';
  }

  if (settings.printErrorData && data != null) {
    final prettyData = encoder.convert(data);
    msg += '\nData: $prettyData';
  }
  if (settings.printErrorHeaders && !(headers?.isEmpty ?? true)) {
    final prettyHeaders = encoder.convert(headers!.map);
    msg += '\nHeaders: $prettyHeaders';
  }
  return msg;
}