Make the IO interface align with the VM API

This commit is contained in:
Natalie Weizenbaum 2021-03-18 21:43:02 -07:00
parent 654744f5f4
commit 102d3cedc2
3 changed files with 11 additions and 3 deletions

View File

@ -88,7 +88,11 @@ Future<void> main(List<String> args) async {
if (exitCode != 66) exitCode = 65;
if (options.stopOnError) return;
} on FileSystemException catch (error, stackTrace) {
printError("Error reading ${p.relative(error.path)}: ${error.message}.",
var path = error.path;
printError(
path == null
? error.message
: "Error reading ${p.relative(path)}: ${error.message}.",
options.trace ? stackTrace : null);
// Error 66 indicates no input.

View File

@ -82,7 +82,11 @@ class _Watcher {
exitCode = 65;
return false;
} on FileSystemException catch (error, stackTrace) {
_printError("Error reading ${p.relative(error.path)}: ${error.message}.",
var path = error.path;
_printError(
path == null
? error.message
: "Error reading ${p.relative(path)}: ${error.message}.",
stackTrace);
exitCode = 66;
return false;

View File

@ -22,7 +22,7 @@ class Stderr {
/// An error thrown by [readFile].
class FileSystemException {
String get message => throw '';
String get path => throw '';
String? get path => throw '';
}
/// The standard error for the current process.