@@ -63,27 +63,34 @@ private void ProcessPackageResolvedFile(ISingleFileComponentRecorder singleFileC
63
63
64
64
foreach ( var package in parsedResolvedFile . Pins )
65
65
{
66
- if ( package . Kind == TargetSwiftPackageKind )
66
+ try
67
67
{
68
- // The version of the package is not always available.
69
- var version = package . State . Version ?? package . State . Branch ?? package . State . Revision ;
70
-
71
- var detectedSwiftComponent = new SwiftComponent (
72
- name : package . Identity ,
73
- version : version ,
74
- packageUrl : package . Location ,
75
- hash : package . State . Revision ) ;
76
- var newDetectedSwiftComponent = new DetectedComponent ( component : detectedSwiftComponent , detector : this ) ;
77
- singleFileComponentRecorder . RegisterUsage ( newDetectedSwiftComponent ) ;
78
-
79
- // We also register a Git component for the same package so that the git URL is registered.
80
- // Swift Package Manager directly downloads the package from the git URL.
81
- var detectedGitComponent = new GitComponent (
82
- repositoryUrl : new Uri ( package . Location ) ,
83
- commitHash : package . State . Revision ,
84
- tag : version ) ;
85
- var newDetectedGitComponent = new DetectedComponent ( component : detectedGitComponent , detector : this ) ;
86
- singleFileComponentRecorder . RegisterUsage ( newDetectedGitComponent ) ;
68
+ if ( package . Kind == TargetSwiftPackageKind )
69
+ {
70
+ // The version of the package is not always available.
71
+ var version = package . State . Version ?? package . State . Branch ?? package . State . Revision ;
72
+
73
+ var detectedSwiftComponent = new SwiftComponent (
74
+ name : package . Identity ,
75
+ version : version ,
76
+ packageUrl : package . Location ,
77
+ hash : package . State . Revision ) ;
78
+ var newDetectedSwiftComponent = new DetectedComponent ( component : detectedSwiftComponent , detector : this ) ;
79
+ singleFileComponentRecorder . RegisterUsage ( newDetectedSwiftComponent ) ;
80
+
81
+ // We also register a Git component for the same package so that the git URL is registered.
82
+ // Swift Package Manager directly downloads the package from the git URL.
83
+ var detectedGitComponent = new GitComponent (
84
+ repositoryUrl : new Uri ( package . Location ) ,
85
+ commitHash : package . State . Revision ,
86
+ tag : version ) ;
87
+ var newDetectedGitComponent = new DetectedComponent ( component : detectedGitComponent , detector : this ) ;
88
+ singleFileComponentRecorder . RegisterUsage ( newDetectedGitComponent ) ;
89
+ }
90
+ }
91
+ catch ( Exception exception )
92
+ {
93
+ this . Logger . LogError ( exception , "SwiftComponentDetector: Error processing package: {Package}" , package . Identity ) ;
87
94
}
88
95
}
89
96
}
0 commit comments