@@ -27,6 +27,7 @@ use symbolic::debuginfo::pe::PeObject;
27
27
use symbolic:: debuginfo:: sourcebundle:: { SourceBundleWriter , SourceFileDescriptor } ;
28
28
use symbolic:: debuginfo:: { Archive , FileEntry , FileFormat , Object } ;
29
29
use symbolic:: il2cpp:: ObjectLineMapping ;
30
+ use thiserror:: Error ;
30
31
use walkdir:: WalkDir ;
31
32
use which:: which;
32
33
use zip:: result:: ZipError ;
@@ -767,7 +768,8 @@ fn collect_auxdif<'a>(
767
768
} ;
768
769
769
770
// Skip this file if we don't want to process it.
770
- if !options. validate_dif ( & dif) {
771
+ if let Err ( e) = options. validate_dif ( & dif) {
772
+ debug ! ( "Skipping dif {name}: {e}" ) ;
771
773
return None ;
772
774
}
773
775
@@ -836,7 +838,9 @@ fn collect_object_dif<'a>(
836
838
// If this is a PE file with an embedded Portable PDB, we extract and process the PPDB separately.
837
839
if let Object :: Pe ( pe) = & object {
838
840
if let Ok ( Some ( ppdb_dif) ) = extract_embedded_ppdb ( pe, name. as_str ( ) ) {
839
- if options. validate_dif ( & ppdb_dif) {
841
+ if let Err ( e) = options. validate_dif ( & ppdb_dif) {
842
+ debug ! ( "Skipping ppdb dif: {e}" ) ;
843
+ } else {
840
844
collected. push ( ppdb_dif) ;
841
845
}
842
846
}
@@ -878,7 +882,9 @@ fn collect_object_dif<'a>(
878
882
} ;
879
883
880
884
// Skip this file if we don't want to process it.
881
- if !options. validate_dif ( & dif) {
885
+ if let Err ( e) = options. validate_dif ( & dif) {
886
+ debug ! ( "Skipping dif {name}: {e}" ) ;
887
+ // TODO: Check if we have a size error, and error if so.
882
888
continue ;
883
889
}
884
890
@@ -1394,6 +1400,24 @@ pub enum DifFormat {
1394
1400
Il2Cpp ,
1395
1401
}
1396
1402
1403
+ #[ derive( Debug , Error ) ]
1404
+ enum DifValidationError < ' s > {
1405
+ #[ error( "{dif_name} has an invalid format" ) ]
1406
+ InvalidFormat { dif_name : & ' s str } ,
1407
+ #[ error( "{dif_name} has invalid features" ) ]
1408
+ InvalidFeatures { dif_name : & ' s str } ,
1409
+ #[ error( "{dif_name} has an invalid debug id" ) ]
1410
+ InvalidDebugId { dif_name : & ' s str } ,
1411
+ #[ error(
1412
+ "Size of {dif_name} is {size} bytes, which exceeds the maximum size of {max_size} bytes"
1413
+ ) ]
1414
+ SizeTooLarge {
1415
+ dif_name : & ' s str ,
1416
+ size : usize ,
1417
+ max_size : u64 ,
1418
+ } ,
1419
+ }
1420
+
1397
1421
/// Searches, processes and uploads debug information files (DIFs).
1398
1422
///
1399
1423
/// This struct is created with the `DifUpload::new` function. Then, set
@@ -1745,33 +1769,34 @@ impl<'a> DifUpload<'a> {
1745
1769
/// This takes all the filters configured in the [`DifUpload`] into account and returns
1746
1770
/// whether a file should be skipped or not. It also takes care of logging such a skip
1747
1771
/// if required.
1748
- fn validate_dif ( & self , dif : & DifMatch ) -> bool {
1772
+ fn validate_dif < ' d > ( & self , dif : & ' d DifMatch ) -> Result < ( ) , DifValidationError < ' d > > {
1749
1773
// Skip if we didn't want this kind of DIF.
1774
+ let dif_name = & dif. name ;
1750
1775
if !self . valid_format ( dif. format ( ) ) {
1751
- debug ! ( "skipping {} because of format" , dif. name) ;
1752
- return false ;
1776
+ return Err ( DifValidationError :: InvalidFormat { dif_name } ) ;
1753
1777
}
1754
1778
1755
1779
// Skip if this DIF does not have features we want.
1756
1780
if !self . valid_features ( dif) {
1757
- debug ! ( "skipping {} because of features" , dif. name) ;
1758
- return false ;
1781
+ return Err ( DifValidationError :: InvalidFeatures { dif_name } ) ;
1759
1782
}
1760
1783
1761
1784
// Skip if this DIF has no DebugId or we are only looking for certain IDs.
1762
1785
let id = dif. debug_id . unwrap_or_default ( ) ;
1763
1786
if id. is_nil ( ) || !self . valid_id ( id) {
1764
- debug ! ( "skipping {} because of debugid" , dif. name) ;
1765
- return false ;
1787
+ return Err ( DifValidationError :: InvalidDebugId { dif_name } ) ;
1766
1788
}
1767
1789
1768
1790
// Skip if file exceeds the maximum allowed file size.
1769
1791
if !self . valid_size ( & dif. name , dif. data ( ) . len ( ) ) {
1770
- debug ! ( "skipping {} because of size" , dif. name) ;
1771
- return false ;
1792
+ return Err ( DifValidationError :: SizeTooLarge {
1793
+ dif_name,
1794
+ size : dif. data ( ) . len ( ) ,
1795
+ max_size : self . max_file_size ,
1796
+ } ) ;
1772
1797
}
1773
1798
1774
- true
1799
+ Ok ( ( ) )
1775
1800
}
1776
1801
1777
1802
fn into_chunk_options ( self , server_options : ChunkServerOptions ) -> ChunkOptions < ' a > {
0 commit comments