@@ -17,7 +17,6 @@ use std::{
17
17
use esp_idf_part:: PartitionTable ;
18
18
use log:: { debug, info, warn} ;
19
19
use md5:: { Digest , Md5 } ;
20
- use miette:: { Context , IntoDiagnostic , Result } ;
21
20
use serde:: { Deserialize , Serialize } ;
22
21
#[ cfg( feature = "serialport" ) ]
23
22
use serialport:: UsbPortInfo ;
@@ -332,7 +331,7 @@ impl<'a> FlashDataBuilder<'a> {
332
331
}
333
332
334
333
/// Builds a [`FlashData`] object.
335
- pub fn build ( self ) -> Result < FlashData > {
334
+ pub fn build ( self ) -> Result < FlashData , Error > {
336
335
FlashData :: new (
337
336
self . bootloader_path ,
338
337
self . partition_table_path ,
@@ -364,12 +363,13 @@ impl FlashData {
364
363
target_app_partition : Option < String > ,
365
364
flash_settings : FlashSettings ,
366
365
min_chip_rev : u16 ,
367
- ) -> Result < Self > {
366
+ ) -> Result < Self , Error > {
368
367
// If the '--bootloader' option is provided, load the binary file at the
369
368
// specified path.
370
369
let bootloader = if let Some ( path) = bootloader {
371
- let path = fs:: canonicalize ( path) . into_diagnostic ( ) ?;
372
- let data: Vec < u8 > = fs:: read ( path) . into_diagnostic ( ) ?;
370
+ let data = fs:: canonicalize ( path)
371
+ . and_then ( fs:: read)
372
+ . map_err ( |e| Error :: FileOpenError ( path. display ( ) . to_string ( ) , e) ) ?;
373
373
374
374
Some ( data)
375
375
} else {
@@ -1176,10 +1176,8 @@ pub(crate) fn checksum(data: &[u8], mut checksum: u8) -> u8 {
1176
1176
}
1177
1177
1178
1178
/// Parse a [PartitionTable] from the provided path
1179
- pub fn parse_partition_table ( path : & Path ) -> Result < PartitionTable > {
1180
- let data = fs:: read ( path)
1181
- . into_diagnostic ( )
1182
- . wrap_err ( "Failed to open partition table" ) ?;
1179
+ pub fn parse_partition_table ( path : & Path ) -> Result < PartitionTable , Error > {
1180
+ let data = fs:: read ( path) . map_err ( |e| Error :: FileOpenError ( path. display ( ) . to_string ( ) , e) ) ?;
1183
1181
1184
- PartitionTable :: try_from ( data) . into_diagnostic ( )
1182
+ Ok ( PartitionTable :: try_from ( data) ? )
1185
1183
}
0 commit comments