@@ -3,11 +3,10 @@ use std::{
33 time:: Duration ,
44} ;
55
6- use binstalk:: errors:: BinstallError ;
7- use binstalk:: helpers:: tasks:: AutoAbortJoinHandle ;
6+ use binstalk:: { errors:: BinstallError , helpers:: tasks:: AutoAbortJoinHandle } ;
87use miette:: Result ;
98use tokio:: runtime:: Runtime ;
10- use tracing:: { error, info} ;
9+ use tracing:: { error, info, warn } ;
1110
1211use crate :: signal:: cancel_on_user_sig_term;
1312
@@ -19,20 +18,28 @@ pub enum MainExit {
1918
2019impl Termination for MainExit {
2120 fn report ( self ) -> ExitCode {
22- match self {
21+ let ( code , err ) = match self {
2322 Self :: Success ( spent) => {
2423 if let Some ( spent) = spent {
2524 info ! ( "Done in {spent:?}" ) ;
2625 }
27- ExitCode :: SUCCESS
26+ return ExitCode :: SUCCESS ;
2827 }
29- Self :: Error ( err) => err. report ( ) ,
30- Self :: Report ( err) => {
31- error ! ( "Fatal error:" ) ;
32- println ! ( "{err:?}" ) ;
33- ExitCode :: from ( 16 )
28+ Self :: Error ( err) => {
29+ let code = err. exit_code ( ) ;
30+ let Some ( report) = err. get_report ( ) else {
31+ warn ! ( "Installation cancelled" ) ;
32+ return code;
33+ } ;
34+ ( code, report)
3435 }
35- }
36+ Self :: Report ( err) => ( ExitCode :: from ( 16 ) , err) ,
37+ } ;
38+
39+ error ! ( "Fatal error:" ) ;
40+ println ! ( "{err:?}" ) ;
41+
42+ code
3643 }
3744}
3845
0 commit comments