Make some errors more idiomatic (flutter/engine#22261)

This commit is contained in:
Yegor
2020-11-03 12:57:51 -08:00
committed by GitHub
parent dbb5e12c09
commit 9ab6d32946
2 changed files with 9 additions and 11 deletions

View File

@@ -186,8 +186,6 @@ class ExecCommandPasteStrategy implements PasteFromClipboardStrategy {
@override
Future<String> getData() {
// TODO(nurhan): https://github.com/flutter/flutter/issues/48581
// TODO(nurhan): https://github.com/flutter/flutter/issues/48580
print('Paste is not implemented for this browser.');
throw UnimplementedError();
throw UnimplementedError('Paste is not implemented for this browser.');
}
}

View File

@@ -347,16 +347,16 @@ abstract class PersistedSurface implements ui.EngineLayer {
/// such as on the very first frame.
@mustCallSuper
void build() {
if (rootElement != null) {
try {
throw '';
} catch (_, stack) {
print(
'Attempted to build a $runtimeType, but it already has an HTML element ${rootElement!.tagName}.');
print(stack.toString().split('\n').take(20).join('\n'));
if (assertionsEnabled) {
final html.Element? existingElement = rootElement;
if (existingElement != null) {
throw PersistedSurfaceException(
this,
'Attempted to build a $runtimeType, but it already has an HTML '
'element ${existingElement.tagName}.',
);
}
}
assert(rootElement == null);
assert(debugAssertSurfaceState(this, PersistedSurfaceState.created));
rootElement = createElement();
assert(rootElement != null);