1818use std:: fs;
1919use std:: path:: Path ;
2020
21+ use crate :: report:: ReportError ;
22+ use crate :: runner:: { EntryResult , HurlResult , RunnerError } ;
2123use hurl_core:: ast:: SourceInfo ;
2224use hurl_core:: input:: Input ;
2325use hurl_core:: parser;
2426use uuid:: Uuid ;
2527
26- use crate :: runner:: { EntryResult , HurlResult , RunnerError } ;
27-
2828#[ derive( Clone , Debug , PartialEq , Eq ) ]
2929pub struct Testcase {
3030 /// Unique identifier of this testcase.
@@ -71,7 +71,7 @@ impl Testcase {
7171 entries : & [ EntryResult ] ,
7272 dir : & Path ,
7373 secrets : & [ & str ] ,
74- ) -> Result < ( ) , crate :: report :: ReportError > {
74+ ) -> Result < ( ) , ReportError > {
7575 // We parse the content as we'll reuse the AST to construct the HTML source file, and
7676 // the waterfall.
7777 // TODO: for the moment, we can only have parseable file.
@@ -80,17 +80,23 @@ impl Testcase {
8080 // We create the timeline view.
8181 let output_file = dir. join ( self . timeline_filename ( ) ) ;
8282 let html = self . get_timeline_html ( & hurl_file, content, entries, secrets) ;
83- fs:: write ( output_file, html. as_bytes ( ) ) ?;
83+ fs:: write ( & output_file, html. as_bytes ( ) ) . map_err ( |e| {
84+ ReportError :: from_io_error ( & e, & output_file, "Issue writing HTML report" )
85+ } ) ?;
8486
8587 // Then create the run view.
8688 let output_file = dir. join ( self . run_filename ( ) ) ;
8789 let html = self . get_run_html ( & hurl_file, content, entries, secrets) ;
88- fs:: write ( output_file, html. as_bytes ( ) ) ?;
90+ fs:: write ( & output_file, html. as_bytes ( ) ) . map_err ( |e| {
91+ ReportError :: from_io_error ( & e, & output_file, "Issue writing HTML report" )
92+ } ) ?;
8993
9094 // And create the source view.
9195 let output_file = dir. join ( self . source_filename ( ) ) ;
9296 let html = self . get_source_html ( & hurl_file, content, secrets) ;
93- fs:: write ( output_file, html. as_bytes ( ) ) ?;
97+ fs:: write ( & output_file, html. as_bytes ( ) ) . map_err ( |e| {
98+ ReportError :: from_io_error ( & e, & output_file, "Issue writing HTML report" )
99+ } ) ?;
94100
95101 Ok ( ( ) )
96102 }
0 commit comments