Change all instance of throwing strings to throw specific error classes. (#97325)
This commit is contained in:
@@ -153,7 +153,7 @@ void testUsingContext(
|
||||
print(error); // ignore: avoid_print
|
||||
print(stackTrace); // ignore: avoid_print
|
||||
_printBufferedErrors(context);
|
||||
throw error;
|
||||
throw error; //ignore: only_throw_errors
|
||||
});
|
||||
},
|
||||
);
|
||||
@@ -348,10 +348,10 @@ class LocalFileSystemBlockingSetCurrentDirectory extends LocalFileSystem {
|
||||
|
||||
@override
|
||||
set currentDirectory(dynamic value) {
|
||||
throw 'globals.fs.currentDirectory should not be set on the local file system during '
|
||||
throw Exception('globals.fs.currentDirectory should not be set on the local file system during '
|
||||
'tests as this can cause race conditions with concurrent tests. '
|
||||
'Consider using a MemoryFileSystem for testing if possible or refactor '
|
||||
'code to not require setting globals.fs.currentDirectory.';
|
||||
'code to not require setting globals.fs.currentDirectory.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -258,7 +258,8 @@ abstract class FakeProcessManager implements ProcessManager {
|
||||
_pid += 1;
|
||||
final FakeCommand fakeCommand = findCommand(command, workingDirectory, environment, encoding);
|
||||
if (fakeCommand.exception != null) {
|
||||
throw fakeCommand.exception!;
|
||||
assert(fakeCommand.exception is Exception || fakeCommand.exception is Error);
|
||||
throw fakeCommand.exception!; // ignore: only_throw_errors
|
||||
}
|
||||
if (fakeCommand.onRun != null) {
|
||||
fakeCommand.onRun!();
|
||||
|
||||
@@ -27,7 +27,7 @@ class TestBuildSystem implements BuildSystem {
|
||||
|
||||
final List<BuildResult> _results;
|
||||
final BuildResult? _singleResult;
|
||||
final Object? _exception;
|
||||
final Exception? _exception;
|
||||
final void Function(Target target, Environment environment)? _onRun;
|
||||
int _nextResult = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user