about summary refs log tree commit diff
path: root/src/rustbook
diff options
context:
space:
mode:
Diffstat (limited to 'src/rustbook')
-rw-r--r--src/rustbook/book.rs8
-rw-r--r--[-rwxr-xr-x]src/rustbook/build.rs11
-rw-r--r--src/rustbook/error.rs6
-rw-r--r--[-rwxr-xr-x]src/rustbook/main.rs0
-rw-r--r--src/rustbook/term.rs2
5 files changed, 18 insertions, 9 deletions
diff --git a/src/rustbook/book.rs b/src/rustbook/book.rs
index 45a864e3378..1d16de2a2fe 100644
--- a/src/rustbook/book.rs
+++ b/src/rustbook/book.rs
@@ -29,8 +29,8 @@ pub struct Book {
 /// A depth-first iterator over a book.
 pub struct BookItems<'a> {
     cur_items: &'a [BookItem],
-    cur_idx: uint,
-    stack: Vec<(&'a [BookItem], uint)>,
+    cur_idx: usize,
+    stack: Vec<(&'a [BookItem], usize)>,
 }
 
 impl<'a> Iterator for BookItems<'a> {
@@ -80,7 +80,7 @@ impl Book {
 pub fn parse_summary<R: Reader>(input: R, src: &Path) -> Result<Book, Vec<String>> {
     fn collapse(stack: &mut Vec<BookItem>,
                 top_items: &mut Vec<BookItem>,
-                to_level: uint) {
+                to_level: usize) {
         loop {
             if stack.len() < to_level { return }
             if stack.len() == 1 {
@@ -141,7 +141,7 @@ pub fn parse_summary<R: Reader>(input: R, src: &Path) -> Result<Book, Vec<String
             };
             let level = cap.name("indent").unwrap().chars().map(|c| {
                 match c {
-                    ' ' => 1u,
+                    ' ' => 1us,
                     '\t' => 4,
                     _ => unreachable!()
                 }
diff --git a/src/rustbook/build.rs b/src/rustbook/build.rs
index db79e0b45e0..1cb5e38e190 100755..100644
--- a/src/rustbook/build.rs
+++ b/src/rustbook/build.rs
@@ -130,8 +130,8 @@ fn render(book: &Book, tgt: &Path) -> CliResult<()> {
         ];
         let output_result = rustdoc::main_args(rustdoc_args);
         if output_result != 0 {
-
-            let message = format!("Could not execute `rustdoc`: {}", output_result);
+            let message = format!("Could not execute `rustdoc` with {:?}: {}",
+                                  rustdoc_args, output_result);
             return Err(box message as Box<Error>);
         }
     }
@@ -172,12 +172,13 @@ impl Subcommand for Build {
         match book::parse_summary(summary, &src) {
             Ok(book) => {
                 // execute rustdoc on the whole book
-                let _ = render(&book, &tgt).map_err(|err| {
+                try!(render(&book, &tgt).map_err(|err| {
                     term.err(&format!("error: {}", err.description())[]);
                     err.detail().map(|detail| {
                         term.err(&format!("detail: {}", detail)[]);
-                    })
-                });
+                    });
+                    err
+                }))
             }
             Err(errors) => {
                 for err in errors.into_iter() {
diff --git a/src/rustbook/error.rs b/src/rustbook/error.rs
index 1d3baef8c1c..a5915ed4d73 100644
--- a/src/rustbook/error.rs
+++ b/src/rustbook/error.rs
@@ -56,6 +56,12 @@ impl Error for String {
     }
 }
 
+impl<'a> Error for Box<Error + 'a> {
+    fn description(&self) -> &str { (**self).description() }
+    fn detail(&self) -> Option<&str> { (**self).detail() }
+    fn cause(&self) -> Option<&Error> { (**self).cause() }
+}
+
 impl FromError<()> for () {
     fn from_err(_: ()) -> () { () }
 }
diff --git a/src/rustbook/main.rs b/src/rustbook/main.rs
index acb4edb7a45..acb4edb7a45 100755..100644
--- a/src/rustbook/main.rs
+++ b/src/rustbook/main.rs
diff --git a/src/rustbook/term.rs b/src/rustbook/term.rs
index 18306d6ec20..471e22ce7c1 100644
--- a/src/rustbook/term.rs
+++ b/src/rustbook/term.rs
@@ -11,6 +11,7 @@
 //! An abstraction of the terminal. Eventually, provide color and
 //! verbosity support. For now, just a wrapper around stdout/stderr.
 
+use std::os;
 use std::io::stdio;
 
 pub struct Term {
@@ -27,5 +28,6 @@ impl Term {
     pub fn err(&mut self, msg: &str) {
         // swallow any errors
         let _ = self.err.write_line(msg);
+        os::set_exit_status(101);
     }
 }