Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Unified Diff: pkg/front_end/lib/file_system.dart

Issue 2864183002: Throw FileSystemException from FileSystemEntity methods. (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/front_end/lib/file_system.dart
diff --git a/pkg/front_end/lib/file_system.dart b/pkg/front_end/lib/file_system.dart
index 0afb39e7a7b72fd7fc812b50da4879f82ffb4364..d0b5975017b8f7802d00c4edc2ee869018f1e74d 100644
--- a/pkg/front_end/lib/file_system.dart
+++ b/pkg/front_end/lib/file_system.dart
@@ -39,12 +39,20 @@ abstract class FileSystemEntity {
/// [FileSystem.entityForUri], since the URI might have been normalized.
Uri get uri;
+ /// Whether this file system entity exists.
+ Future<bool> exists();
+
+ /// Extracts the last-modification time of the file system entity, if it
+ /// exists and it is a file, otherwise the future is completed with
+ /// [FileSystemException].
+ Future<DateTime> lastModified();
+
/// Attempts to access this file system entity as a file and read its contents
/// as raw bytes.
///
/// If an error occurs while attempting to read the file (e.g. because no such
/// file exists, or the entity is a directory), the future is completed with
- /// an [Exception].
+ /// [FileSystemException].
Future<List<int>> readAsBytes();
/// Attempts to access this file system entity as a file and read its contents
@@ -54,14 +62,19 @@ abstract class FileSystemEntity {
///
/// If an error occurs while attempting to read the file (e.g. because no such
/// file exists, the entity is a directory, or the file is not valid UTF-8),
- /// the future is completed with an [Exception].
+ /// the future is completed with [FileSystemException].
Future<String> readAsString();
+}
- /// Whether this file system entity exists.
- Future<bool> exists();
+/**
+ * Base class for all file system exceptions.
+ */
+class FileSystemException implements Exception {
+ final Uri uri;
+ final String message;
- /// Extracts the last-modification time of the file system entity, if it
- /// exists and it is a file, otherwise the future is completed with an
- /// [Exception].
- Future<DateTime> lastModified();
+ FileSystemException(this.uri, this.message);
+
+ @override
+ String toString() => 'FileSystemException(uri=$uri; message=$message)';
}
« no previous file with comments | « no previous file | pkg/front_end/lib/memory_file_system.dart » ('j') | pkg/front_end/lib/physical_file_system.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698