Handle Go Replace Exceptions (#1273)
* handle version exceptions * adding log warning * adding module names --------- Co-authored-by: Amitla Vannikumar <avannikumar@microsoft.com>
This commit is contained in:
Родитель
96cc922b48
Коммит
ae287518d4
|
@ -7,4 +7,6 @@ public class GoReplaceTelemetryRecord : BaseDetectionTelemetryRecord
|
|||
public string GoModPathAndVersion { get; set; }
|
||||
|
||||
public string GoModReplacement { get; set; }
|
||||
|
||||
public string ExceptionMessage { get; set; }
|
||||
}
|
||||
|
|
|
@ -477,10 +477,19 @@ public class GoComponentDetector : FileComponentDetector
|
|||
if (dependency.Replace?.Path != null && dependency.Replace.Version != null)
|
||||
{
|
||||
var dependencyReplacementName = $"{dependency.Replace.Path} {dependency.Replace.Version}";
|
||||
goComponent = new GoComponent(dependency.Replace.Path, dependency.Replace.Version);
|
||||
this.Logger.LogInformation("go Module {GoModule} being replaced with module {GoModuleReplacement}", dependencyName, dependencyReplacementName);
|
||||
record.GoModPathAndVersion = dependencyName;
|
||||
record.GoModReplacement = dependencyReplacementName;
|
||||
try
|
||||
{
|
||||
goComponent = new GoComponent(dependency.Replace.Path, dependency.Replace.Version);
|
||||
this.Logger.LogInformation("go Module {GoModule} being replaced with module {GoModuleReplacement}", dependencyName, dependencyReplacementName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
record.ExceptionMessage = ex.Message;
|
||||
this.Logger.LogWarning("tried to use replace module {GoModuleReplacement} but got this error {ErrorMessage} using original module {GoModule} instead", dependencyReplacementName, ex.Message, dependencyName);
|
||||
goComponent = new GoComponent(dependency.Path, dependency.Version);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче