@@ -33,6 +33,8 @@ mod tracing;
33
33
mod turbo_json;
34
34
mod unescape;
35
35
36
+ use miette:: Report ;
37
+
36
38
pub use crate :: {
37
39
child:: spawn_child,
38
40
cli:: Args ,
@@ -41,7 +43,7 @@ pub use crate::{
41
43
execution_state:: ExecutionState ,
42
44
run:: package_discovery:: DaemonPackageDiscovery ,
43
45
} ;
44
- use crate :: { commands :: CommandBase , engine :: BuilderError } ;
46
+ use crate :: { engine :: BuilderError , shim :: Error } ;
45
47
46
48
pub fn get_version ( ) -> & ' static str {
47
49
include_str ! ( "../../../version.txt" )
@@ -53,5 +55,37 @@ pub fn get_version() -> &'static str {
53
55
}
54
56
55
57
pub fn main ( ) -> Result < i32 , shim:: Error > {
56
- shim:: run ( )
58
+ match shim:: run ( ) {
59
+ Ok ( code) => Ok ( code) ,
60
+ // We only print using miette for some errors because we want to keep
61
+ // compatibility with Go. When we've deleted the Go code we can
62
+ // move all errors to miette since it provides slightly nicer
63
+ // printing out of the box.
64
+ Err (
65
+ err @ ( Error :: MultipleCwd ( ..)
66
+ | Error :: EmptyCwd { .. }
67
+ | Error :: Cli ( cli:: Error :: Run ( run:: Error :: Builder ( engine:: BuilderError :: Config (
68
+ config:: Error :: InvalidEnvPrefix { .. } ,
69
+ ) ) ) )
70
+ | Error :: Cli ( cli:: Error :: Run ( run:: Error :: Config (
71
+ config:: Error :: TurboJsonParseError ( _) ,
72
+ ) ) )
73
+ | Error :: Cli ( cli:: Error :: Run ( run:: Error :: Builder ( BuilderError :: Config (
74
+ config:: Error :: TurboJsonParseError ( _) ,
75
+ ) ) ) ) ) ,
76
+ ) => {
77
+ println ! ( "{:?}" , Report :: new( err) ) ;
78
+
79
+ Ok ( 1 )
80
+ }
81
+ // We don't need to print "Turbo error" for Run errors
82
+ Err ( err @ shim:: Error :: Cli ( cli:: Error :: Run ( _) ) ) => Err ( err) ,
83
+ Err ( err) => {
84
+ // This raw print matches the Go behavior, once we no longer care
85
+ // about matching formatting we should remove this.
86
+ println ! ( "Turbo error: {err}" ) ;
87
+
88
+ Err ( err)
89
+ }
90
+ }
57
91
}
0 commit comments