implement override of toString() in order to print useful message in release mode as well as debug mode (#118263)

Added `_ErrorDescription.toString()`
This commit is contained in:
Daniel Austin 2023-03-01 02:08:52 +01:00 committed by GitHub
parent b3f7699def
commit b10f25c603
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View file

@ -223,6 +223,13 @@ abstract class _ErrorDiagnostic extends DiagnosticsProperty<List<Object>> {
level: level,
);
@override
String toString({
TextTreeConfiguration? parentConfiguration,
DiagnosticLevel minLevel = DiagnosticLevel.info,
}) {
return valueToString(parentConfiguration: parentConfiguration);
}
@override
List<Object> get value => super.value!;

View file

@ -16,6 +16,13 @@ void main() {
expect(log[1], contains('debugPrintStack'));
});
test('should show message of ErrorDescription', () {
const String descriptionMessage = 'This is the message';
final ErrorDescription errorDescription = ErrorDescription(descriptionMessage);
expect(errorDescription.toString(), descriptionMessage);
});
test('debugPrintStack', () {
final List<String> log = captureOutput(() {
final FlutterErrorDetails details = FlutterErrorDetails(