@@ -11,6 +11,7 @@ use crate::yaml::{
11
11
get_build_lang, get_build_os, get_lang, get_no_deploy, get_os, get_update, get_yaml,
12
12
} ;
13
13
use exitfailure:: ExitFailure ;
14
+ use failure:: ResultExt ;
14
15
use log:: { debug, error, info} ;
15
16
use std:: fmt:: Display ;
16
17
use std:: path:: PathBuf ;
@@ -148,29 +149,44 @@ fn main() -> Result<(), ExitFailure> {
148
149
. to_str( )
149
150
. unwrap_or( "Filename not convertible" )
150
151
) ;
151
- let config = crate :: config:: get_config ( & opt. configfile ) ?;
152
+ let config = crate :: config:: get_config ( & opt. configfile ) . with_context ( |_| {
153
+ format ! (
154
+ "could not parse the file {}" ,
155
+ opt. configfile. to_str( ) . unwrap_or( "file name not printable" )
156
+ )
157
+ } ) ?;
152
158
let prj = Project {
153
159
owner : opt. user_name . clone ( ) ,
154
160
project : opt. project_name . clone ( ) ,
155
161
} ;
156
- let ( rs, _) = get_status ( & prj, & config. tokens . github ) ?;
162
+ let ( rs, _) = get_status ( & prj, & config. tokens . github ) . with_context ( |_| {
163
+ format ! (
164
+ "Fecth repository data failed for user {} project {}" ,
165
+ prj. owner, prj. project,
166
+ )
167
+ } ) ?;
157
168
println ! ( "github repository information:\n {}" , rs) ;
158
169
/* fetch the repo to read the .bsd-ci file */
159
- let path = crate :: pot:: fetch_git_in_fscomp ( & prj, & rs, & opt) ?;
170
+ let path = crate :: pot:: fetch_git_in_fscomp ( & prj, & rs, & opt) . with_context ( |_| {
171
+ "Failed to create a ZFS dataset with the project in it\n Is pot installed?\n Are you root?"
172
+ } ) ?;
160
173
161
174
println ! ( "Git repo fetched in {}" , path) ;
162
175
163
176
let mut build_queue = Vec :: new ( ) ;
164
177
let mut build_opt = BuildOpt :: default ( ) ;
165
- let yaml_string = get_yaml ( & path) ?;
166
- let docs = YamlLoader :: load_from_str ( & yaml_string) ?;
178
+ let yaml_string =
179
+ get_yaml ( & path) . with_context ( |_| "Error accessing the yaml file in the project" ) ?;
180
+ let docs = YamlLoader :: load_from_str ( & yaml_string)
181
+ . with_context ( |_| "Error parsing the yaml file in the project" ) ?;
167
182
for d in docs {
168
183
let h = d. into_hash ( ) . unwrap ( ) ;
169
184
debug ! ( "{:?}" , h) ;
170
- let lang = get_lang ( & h) ?;
171
- let os = get_os ( & h) ?;
185
+ let lang = get_lang ( & h) . with_context ( |_| "Invalid YAML" ) ?;
186
+ let os = get_os ( & h) . with_context ( |_| "Invalid YAML" ) ?;
172
187
let build_lang = match lang. as_ref ( ) {
173
- "rust" => get_build_lang ( "rust" , & h) ?,
188
+ "rust" => get_build_lang ( "rust" , & h)
189
+ . with_context ( |_| format ! ( "Ivalid YAML for language {}" , lang) ) ?,
174
190
_ => {
175
191
return Err ( ExitFailure :: from ( ParseError :: GenericError {
176
192
msg : "language not supported" . to_string ( ) ,
0 commit comments