Unverified Commit 2939c209 authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

Update error message for bad UTF-8 decoding (#62888)

parent 6b7634b7
...@@ -11,7 +11,10 @@ import 'base/common.dart'; ...@@ -11,7 +11,10 @@ import 'base/common.dart';
export 'dart:convert' hide utf8, Utf8Codec, Utf8Decoder; export 'dart:convert' hide utf8, Utf8Codec, Utf8Decoder;
/// A [Codec] which reports malformed bytes when decoding. /// A [Codec] which reports malformed bytes when decoding.
// Created to solve https://github.com/flutter/flutter/issues/15646. ///
/// Occasionally people end up in a situation where we try to decode bytes
/// that aren't UTF-8 and we're not quite sure how this is happening.
/// This tells people to report a bug when they see this.
class Utf8Codec extends Encoding { class Utf8Codec extends Encoding {
const Utf8Codec(); const Utf8Codec();
...@@ -40,8 +43,9 @@ class Utf8Decoder extends cnv.Utf8Decoder { ...@@ -40,8 +43,9 @@ class Utf8Decoder extends cnv.Utf8Decoder {
if (reportErrors && result.contains('\u{FFFD}')) { if (reportErrors && result.contains('\u{FFFD}')) {
throwToolExit( throwToolExit(
'Bad UTF-8 encoding found while decoding string: $result. ' 'Bad UTF-8 encoding found while decoding string: $result. '
'The Flutter team would greatly appreciate if you could file a bug or leave a ' 'The Flutter team would greatly appreciate if you could file a bug explaining '
'comment on the issue https://github.com/flutter/flutter/issues/15646.\n' 'exactly what you were doing when this happened:\n'
'https://github.com/flutter/flutter/issues/new/choose\n'
'The source bytes were:\n$codeUnits\n\n'); 'The source bytes were:\n$codeUnits\n\n');
} }
return result; return result;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment