mirror of
https://github.com/flutter/packages.git
synced 2025-06-30 23:03:11 +08:00
[webview_flutter_wkwebview] NSError.toString (#4441)
Fixes https://github.com/flutter/flutter/issues/128596
This commit is contained in:
@ -1,3 +1,7 @@
|
||||
## 3.6.3
|
||||
|
||||
* Introduces `NSError.toString` for better diagnostics.
|
||||
|
||||
## 3.6.2
|
||||
|
||||
* Fixes unawaited_futures violations.
|
||||
|
@ -215,7 +215,7 @@ class NSError {
|
||||
|
||||
/// The error code.
|
||||
///
|
||||
/// Note that errors are domain-specific.
|
||||
/// Error codes are [domain]-specific.
|
||||
final int code;
|
||||
|
||||
/// A string containing the error domain.
|
||||
@ -223,6 +223,14 @@ class NSError {
|
||||
|
||||
/// A string containing the localized description of the error.
|
||||
final String localizedDescription;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (localizedDescription.isEmpty) {
|
||||
return 'Error $domain:$code';
|
||||
}
|
||||
return '$localizedDescription ($domain:$code)';
|
||||
}
|
||||
}
|
||||
|
||||
/// A representation of an HTTP cookie.
|
||||
|
@ -2,7 +2,7 @@ name: webview_flutter_wkwebview
|
||||
description: A Flutter plugin that provides a WebView widget based on Apple's WKWebView control.
|
||||
repository: https://github.com/flutter/packages/tree/main/packages/webview_flutter/webview_flutter_wkwebview
|
||||
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+webview%22
|
||||
version: 3.6.2
|
||||
version: 3.6.3
|
||||
|
||||
environment:
|
||||
sdk: ">=2.18.0 <4.0.0"
|
||||
|
@ -246,4 +246,39 @@ void main() {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('NSError', () {
|
||||
expect(
|
||||
const NSError(
|
||||
code: 0,
|
||||
domain: 'domain',
|
||||
localizedDescription: 'desc',
|
||||
).toString(),
|
||||
'desc (domain:0)',
|
||||
);
|
||||
expect(
|
||||
const NSError(
|
||||
code: 0,
|
||||
domain: 'domain',
|
||||
localizedDescription: '',
|
||||
).toString(),
|
||||
'Error domain:0',
|
||||
);
|
||||
expect(
|
||||
const NSError(
|
||||
code: 255,
|
||||
domain: 'bar',
|
||||
localizedDescription: 'baz',
|
||||
).toString(),
|
||||
'baz (bar:255)',
|
||||
);
|
||||
expect(
|
||||
const NSError(
|
||||
code: 255,
|
||||
domain: 'bar',
|
||||
localizedDescription: '',
|
||||
).toString(),
|
||||
'Error bar:255',
|
||||
);
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user