Skip to content

Commit 667bb26

Browse files
committed
Rename ErrorString to ErrorMessage
1 parent 2e89280 commit 667bb26

File tree

8 files changed

+27
-28
lines changed

8 files changed

+27
-28
lines changed

Changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
- Move crate to 2018 edition
2121
- Refactor and cleanup the code
2222
- Remove the dependency on `failure`
23-
- Use a custom `ErrorString` type instead
23+
- Use a custom `ErrorMessage` type instead
2424
- Add a new `run-args` config key
2525
- Add a new `--quiet` argument to suppress output
2626

src/args.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use crate::{config::Config, Command, ErrorString};
1+
use crate::{config::Config, Command, ErrorMessage};
22
use std::path::{Path, PathBuf};
33
use std::{env, mem};
44

5-
pub(crate) fn parse_args() -> Result<Command, ErrorString> {
5+
pub(crate) fn parse_args() -> Result<Command, ErrorMessage> {
66
let mut args = env::args();
77
let executable_name = args.next().ok_or("no first argument (executable name)")?;
88
let first = args.next();
@@ -36,7 +36,7 @@ pub(crate) fn parse_args() -> Result<Command, ErrorString> {
3636
}
3737
}
3838

39-
fn parse_build_args<A>(args: A) -> Result<Command, ErrorString>
39+
fn parse_build_args<A>(args: A) -> Result<Command, ErrorMessage>
4040
where
4141
A: Iterator<Item = String>,
4242
{
@@ -49,7 +49,7 @@ where
4949
let mut run_args_started = false;
5050
let mut quiet = false;
5151
{
52-
fn set<T>(arg: &mut Option<T>, value: Option<T>) -> Result<(), ErrorString> {
52+
fn set<T>(arg: &mut Option<T>, value: Option<T>) -> Result<(), ErrorMessage> {
5353
let previous = mem::replace(arg, value);
5454
if previous.is_some() {
5555
Err("multiple arguments of same type provided")?
@@ -209,7 +209,7 @@ impl Args {
209209
}
210210
}
211211

212-
fn parse_runner_args<A>(args: A) -> Result<Command, ErrorString>
212+
fn parse_runner_args<A>(args: A) -> Result<Command, ErrorMessage>
213213
where
214214
A: Iterator<Item = String>,
215215
{
@@ -257,4 +257,3 @@ pub struct RunnerArgs {
257257
/// Suppress any output to stdout.
258258
pub quiet: bool,
259259
}
260-

src/config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::ErrorString;
1+
use crate::ErrorMessage;
22
use std::path::PathBuf;
33
use toml::Value;
44

@@ -11,13 +11,13 @@ pub struct Config {
1111
pub test_timeout: u32,
1212
}
1313

14-
pub(crate) fn read_config(manifest_path: PathBuf) -> Result<Config, ErrorString> {
14+
pub(crate) fn read_config(manifest_path: PathBuf) -> Result<Config, ErrorMessage> {
1515
let config = read_config_inner(manifest_path)
1616
.map_err(|err| format!("Failed to read bootimage configuration: {:?}", err))?;
1717
Ok(config)
1818
}
1919

20-
pub(crate) fn read_config_inner(manifest_path: PathBuf) -> Result<Config, ErrorString> {
20+
pub(crate) fn read_config_inner(manifest_path: PathBuf) -> Result<Config, ErrorMessage> {
2121
use std::{fs::File, io::Read};
2222
let cargo_toml: Value = {
2323
let mut content = String::new();

src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub fn lib_main() {
3636
}
3737
}
3838

39-
pub fn run() -> Result<Option<i32>, ErrorString> {
39+
pub fn run() -> Result<Option<i32>, ErrorMessage> {
4040
let command = args::parse_args()?;
4141
let none = |()| None;
4242
match command {
@@ -54,22 +54,22 @@ pub fn run() -> Result<Option<i32>, ErrorString> {
5454
}
5555
}
5656

57-
pub struct ErrorString {
57+
pub struct ErrorMessage {
5858
pub message: Box<dyn fmt::Display + Send>,
5959
}
6060

61-
impl fmt::Debug for ErrorString {
61+
impl fmt::Debug for ErrorMessage {
6262
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
6363
self.message.fmt(f)
6464
}
6565
}
6666

67-
impl<T> From<T> for ErrorString
67+
impl<T> From<T> for ErrorMessage
6868
where
6969
T: fmt::Display + Send + 'static,
7070
{
7171
fn from(err: T) -> Self {
72-
ErrorString {
72+
ErrorMessage {
7373
message: Box::new(err),
7474
}
7575
}

src/subcommand/build.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use crate::{args::Args, builder::Builder, config, ErrorString};
1+
use crate::{args::Args, builder::Builder, config, ErrorMessage};
22
use std::{path::PathBuf, process};
33

4-
pub(crate) fn build(mut args: Args) -> Result<(), ErrorString> {
4+
pub(crate) fn build(mut args: Args) -> Result<(), ErrorMessage> {
55
let builder = Builder::new(args.manifest_path().clone())?;
66
let config = config::read_config(builder.kernel_manifest_path().to_owned())?;
77
args.apply_default_target(&config, builder.kernel_root());
@@ -14,7 +14,7 @@ pub(crate) fn build_impl(
1414
builder: &Builder,
1515
args: &Args,
1616
quiet: bool,
17-
) -> Result<Vec<PathBuf>, ErrorString> {
17+
) -> Result<Vec<PathBuf>, ErrorMessage> {
1818
run_cargo_fetch(&args);
1919

2020
let executables = builder.build_kernel(&args.cargo_args, quiet)?;

src/subcommand/run.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use crate::{args::Args, builder::Builder, config, ErrorString};
1+
use crate::{args::Args, builder::Builder, config, ErrorMessage};
22
use std::process;
33

4-
pub(crate) fn run(mut args: Args) -> Result<i32, ErrorString> {
4+
pub(crate) fn run(mut args: Args) -> Result<i32, ErrorMessage> {
55
use crate::subcommand::build;
66

77
let builder = Builder::new(args.manifest_path().clone())?;
@@ -23,7 +23,7 @@ pub(crate) fn run(mut args: Args) -> Result<i32, ErrorString> {
2323
"{}",
2424
bootimage_path
2525
.to_str()
26-
.ok_or(ErrorString::from("bootimage path is not valid unicode"))?,
26+
.ok_or(ErrorMessage::from("bootimage path is not valid unicode"))?,
2727
),
2828
);
2929
}
@@ -32,7 +32,7 @@ pub(crate) fn run(mut args: Args) -> Result<i32, ErrorString> {
3232
}
3333
command.args(&args.run_args);
3434
let exit_status = command.status().map_err(|err| {
35-
ErrorString::from(format!(
35+
ErrorMessage::from(format!(
3636
"Failed to execute run command `{:?}`: {}",
3737
command, err
3838
))

src/subcommand/runner.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use crate::{args::RunnerArgs, builder::Builder, config, ErrorString};
1+
use crate::{args::RunnerArgs, builder::Builder, config, ErrorMessage};
22
use std::process;
33

4-
pub(crate) fn runner(args: RunnerArgs) -> Result<i32, ErrorString> {
4+
pub(crate) fn runner(args: RunnerArgs) -> Result<i32, ErrorMessage> {
55
let builder = Builder::new(None)?;
66
let config = config::read_config(builder.kernel_manifest_path().to_owned())?;
77

src/subcommand/test.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
use crate::{args::Args, builder::Builder, config, subcommand::build, ErrorString};
1+
use crate::{args::Args, builder::Builder, config, subcommand::build, ErrorMessage};
22
use rayon::prelude::*;
33
use std::{fs, io, io::Write, process, time::Duration};
44
use wait_timeout::ChildExt;
55

6-
pub(crate) fn test(mut args: Args) -> Result<(), ErrorString> {
6+
pub(crate) fn test(mut args: Args) -> Result<(), ErrorMessage> {
77
let builder = Builder::new(args.manifest_path().clone())?;
88
let config = config::read_config(builder.kernel_manifest_path().to_owned())?;
99
args.apply_default_target(&config, builder.kernel_root());
@@ -83,7 +83,7 @@ pub(crate) fn test(mut args: Args) -> Result<(), ErrorString> {
8383

8484
Ok((target.name.clone(), test_result))
8585
})
86-
.collect::<Result<Vec<(String, TestResult)>, ErrorString>>()?;
86+
.collect::<Result<Vec<(String, TestResult)>, ErrorMessage>>()?;
8787

8888
println!("");
8989
if tests.iter().all(|t| t.1 == TestResult::Ok) {
@@ -102,7 +102,7 @@ fn handle_exit_status(
102102
exit_status: process::ExitStatus,
103103
output: &str,
104104
target_name: &str,
105-
) -> Result<TestResult, ErrorString> {
105+
) -> Result<TestResult, ErrorMessage> {
106106
match exit_status.code() {
107107
None => {
108108
writeln!(io::stderr(), "FAIL: No Exit Code.")?;

0 commit comments

Comments
 (0)