@@ -286,9 +286,9 @@ pub enum PartitionTableError {
286
286
#[ error( "Malformed partition table" ) ]
287
287
#[ diagnostic(
288
288
code( espflash:: partition_table:: mallformed) ,
289
- help( "See the espressif documentation for information on the partition table format:
289
+ help( "{} See the espressif documentation for information on the partition table format:
290
290
291
- https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/partition-tables.html#creating-custom-tables" )
291
+ https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/partition-tables.html#creating-custom-tables" , self . help )
292
292
) ]
293
293
pub struct CSVError {
294
294
#[ source_code]
@@ -298,6 +298,7 @@ pub struct CSVError {
298
298
hint : String ,
299
299
#[ source]
300
300
error : csv:: Error ,
301
+ help : String ,
301
302
}
302
303
303
304
impl CSVError {
@@ -307,7 +308,7 @@ impl CSVError {
307
308
csv:: ErrorKind :: UnequalLengths { pos : Some ( pos) , .. } => pos. line ( ) ,
308
309
_ => 0 ,
309
310
} ;
310
- let hint = match error. kind ( ) {
311
+ let mut hint = match error. kind ( ) {
311
312
csv:: ErrorKind :: Deserialize { err, .. } => err. to_string ( ) ,
312
313
csv:: ErrorKind :: UnequalLengths {
313
314
expected_len, len, ..
@@ -317,6 +318,20 @@ impl CSVError {
317
318
) ,
318
319
_ => String :: new ( ) ,
319
320
} ;
321
+ let mut help = String :: new ( ) ;
322
+
323
+ // string matching is fragile but afaik there is no better way in this case
324
+ // and if it does break the error is still not bad
325
+ if hint == "data did not match any variant of untagged enum SubType" {
326
+ hint = "Unknown sub-type" . into ( ) ;
327
+ help = format ! (
328
+ "the following sub-types are supported:
329
+ {} for data partitions
330
+ {} for app partitions\n \n " ,
331
+ Type :: Data . subtype_hint( ) ,
332
+ Type :: App . subtype_hint( )
333
+ )
334
+ }
320
335
321
336
let err_span = line_to_span ( & source, err_line as usize ) ;
322
337
@@ -325,6 +340,7 @@ impl CSVError {
325
340
err_span,
326
341
hint,
327
342
error,
343
+ help,
328
344
}
329
345
}
330
346
}
0 commit comments