Skip to content
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.

Commit

Permalink
Merge #333
Browse files Browse the repository at this point in the history
333: Clean up `enum Outcome` r=BriocheBerlin a=Urhengulas

A small drive-by PR to clean up `enum Outcome` in the `backtrace` module.

Co-authored-by: Urhengulas <johann.hemmann@code.berlin>
  • Loading branch information
bors[bot] and Urhengulas committed Jul 27, 2022
2 parents bcaf997 + 949164a commit e2b8243
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p

## [Unreleased]

- [#333] Clean up `enum Outcome`
- [#331] Refactor stack painting
- [#330] Fix `fn round_up`
- [#329] Update probe-rs to 0.13.0 (does not yet implement 64-bit support)
Expand All @@ -18,6 +19,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- [#314] Clarify documentation in README
- [#293] Update snapshot tests to new TRACE output

[#333]: https://github.com/knurling-rs/probe-run/pull/333
[#331]: https://github.com/knurling-rs/probe-run/pull/331
[#330]: https://github.com/knurling-rs/probe-run/pull/330
[#329]: https://github.com/knurling-rs/probe-run/pull/329
Expand Down
21 changes: 7 additions & 14 deletions src/backtrace/mod.rs
Expand Up @@ -92,29 +92,22 @@ pub(crate) enum Outcome {
HardFault,
Ok,
StackOverflow,
CtrlC, // control-c was pressed
/// Control-C was pressed
CtrlC,
}

impl Outcome {
pub(crate) fn log(&self) {
match self {
Outcome::StackOverflow => {
log::error!("the program has overflowed its stack");
}
Outcome::HardFault => {
log::error!("the program panicked");
}
Outcome::Ok => {
log::info!("device halted without error");
}
Outcome::CtrlC => {
log::info!("device halted by user");
}
Outcome::StackOverflow => log::error!("the program has overflowed its stack"),
Outcome::HardFault => log::error!("the program panicked"),
Outcome::Ok => log::info!("device halted without error"),
Outcome::CtrlC => log::info!("device halted by user"),
}
}
}

/// Converts `Outcome` to an exit code.
// Convert `Outcome` to an exit code.
impl From<Outcome> for i32 {
fn from(outcome: Outcome) -> i32 {
match outcome {
Expand Down

0 comments on commit e2b8243

Please sign in to comment.