rust/rhg/src/error.rs
changeset 45984 fada33872b5b
parent 45937 2ad2745e0be9
child 46434 3e2d539d0d1a
--- a/rust/rhg/src/error.rs	Mon Nov 30 10:18:36 2020 +0100
+++ b/rust/rhg/src/error.rs	Thu Nov 26 09:54:16 2020 +0100
@@ -1,5 +1,6 @@
 use crate::exitcode;
 use crate::ui::UiError;
+use format_bytes::format_bytes;
 use hg::operations::{FindRootError, FindRootErrorKind};
 use hg::requirements::RequirementsError;
 use hg::utils::files::get_bytes_from_path;
@@ -44,27 +45,17 @@
     /// Return the message corresponding to the error kind if any
     pub fn get_error_message_bytes(&self) -> Option<Vec<u8>> {
         match self {
-            // TODO use formating macro
             CommandErrorKind::RootNotFound(path) => {
                 let bytes = get_bytes_from_path(path);
-                Some(
-                    [
-                        b"abort: no repository found in '",
-                        bytes.as_slice(),
-                        b"' (.hg not found)!\n",
-                    ]
-                    .concat(),
-                )
+                Some(format_bytes!(
+                    b"abort: no repository found in '{}' (.hg not found)!\n",
+                    bytes.as_slice()
+                ))
             }
-            // TODO use formating macro
-            CommandErrorKind::CurrentDirNotFound(e) => Some(
-                [
-                    b"abort: error getting current working directory: ",
-                    e.to_string().as_bytes(),
-                    b"\n",
-                ]
-                .concat(),
-            ),
+            CommandErrorKind::CurrentDirNotFound(e) => Some(format_bytes!(
+                b"abort: error getting current working directory: {}\n",
+                e.to_string().as_bytes(),
+            )),
             CommandErrorKind::RequirementsError(
                 RequirementsError::Corrupted,
             ) => Some(