@@ -49,20 +49,27 @@ public Reports(ILogTracer log, IContainers containers) {
4949 return ParseReportOrRegression ( blob . ToString ( ) , filePath , reportUrl , expectReports ) ;
5050 }
5151
52+ private static T ? TryDeserialize < T > ( string content ) where T : class {
53+ try {
54+ return JsonSerializer . Deserialize < T > ( content , EntityConverter . GetJsonSerializerOptions ( ) ) ;
55+ } catch ( JsonException ) {
56+ return null ;
57+ }
58+ }
59+
5260 private IReport ? ParseReportOrRegression ( string content , string ? filePath , Uri ? reportUrl , bool expectReports = false ) {
53- var regressionReport = JsonSerializer . Deserialize < RegressionReport > ( content , EntityConverter . GetJsonSerializerOptions ( ) ) ;
54- if ( regressionReport == null || regressionReport . CrashTestResult == null ) {
55- try {
56- var report = JsonSerializer . Deserialize < Report > ( content , EntityConverter . GetJsonSerializerOptions ( ) ) ;
57- return report != null ? report with { ReportUrl = reportUrl } : report ;
58- } catch ( JsonException e ) {
59- if ( expectReports ) {
60- _log . Error ( $ "unable to parse report ({ filePath : Tag:FilePath} ) as a report or regression - { e } ") ;
61- }
62- return null ;
63- }
61+ var regressionReport = TryDeserialize < RegressionReport > ( content ) ;
62+ if ( regressionReport != null && regressionReport . CrashTestResult != null ) {
63+ return regressionReport with { ReportUrl = reportUrl } ;
64+ }
65+ var report = TryDeserialize < Report > ( content ) ;
66+ if ( report != null ) {
67+ return report with { ReportUrl = reportUrl } ;
6468 }
65- return regressionReport != null ? regressionReport with { ReportUrl = reportUrl } : regressionReport ;
69+ if ( expectReports ) {
70+ _log . Error ( $ "unable to parse report ({ filePath : Tag:FilePath} ) as a report or regression") ;
71+ }
72+ return null ;
6673 }
6774}
6875
0 commit comments