about summary refs log tree commit diff
path: root/src/comp/syntax/codemap.rs
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2011-10-28 21:19:59 -0700
committerBrian Anderson <banderson@mozilla.com>2011-10-29 01:25:11 -0700
commit2cebef095e61608a3d35710cb5fd3d7de18b68ac (patch)
treecb24a5d2506444d157edfe16fac08f2d31892a28 /src/comp/syntax/codemap.rs
parent2b62a80202e2855d47f20d271842e0e9aec6d8e2 (diff)
downloadrust-2cebef095e61608a3d35710cb5fd3d7de18b68ac.tar.gz
rust-2cebef095e61608a3d35710cb5fd3d7de18b68ac.zip
stdlib: Make io failures recoverable by returning a result
Diffstat (limited to 'src/comp/syntax/codemap.rs')
-rw-r--r--src/comp/syntax/codemap.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/comp/syntax/codemap.rs b/src/comp/syntax/codemap.rs
index 5156570c8ba..2db5e1e2c4c 100644
--- a/src/comp/syntax/codemap.rs
+++ b/src/comp/syntax/codemap.rs
@@ -1,4 +1,4 @@
-import std::{vec, uint, str, term, io, option};
+import std::{vec, uint, str, term, io, option, result};
 import std::option::{some, none};
 
 type filename = str;
@@ -154,7 +154,13 @@ fn maybe_highlight_lines(sp: option::t<span>, cm: codemap,
 
         // FIXME: reading in the entire file is the worst possible way to
         //        get access to the necessary lines.
-        let file = io::read_whole_file_str(lines.name);
+        let file = alt io::read_whole_file_str(lines.name) {
+          result::ok(file) { file }
+          result::err(e) {
+            emit_error(none, e, cm);
+            fail;
+          }
+        };
         let fm = get_filemap(cm, lines.name);
 
         // arbitrarily only print up to six lines of the error