@@ -152,7 +152,14 @@ IImmutableDictionary<IImmutableList<string>, IReadOnlyList<byte>> compileNew()
152
152
var otherErrorsText =
153
153
string . Join ( "\n " , otherErrors . Select ( DescribeCompilationError ) ) ;
154
154
155
- throw new Exception ( "Failed compilation with " + compilationErrors . Count + " errors:\n " + otherErrorsText ) ;
155
+ /*
156
+ * TODO: To clean up the appearance in the (CL) user interface, avoid burying the error message in a large stack trace:
157
+ * Propagate the errors further without runtime exception.
158
+ * New C# features might help simplify the syntax to implement this so that implementation might be easier after switching to .NET 6.
159
+ * Until then, add line breaks to the message to help spot this within a larger output.
160
+ * */
161
+
162
+ throw new Exception ( "Failed compilation with " + compilationErrors . Count + " errors:\n " + otherErrorsText + "\n \n " ) ;
156
163
}
157
164
158
165
byte [ ] ElmMake (
@@ -440,11 +447,27 @@ static byte[] GetManifestResourceStreamContent(string name)
440
447
}
441
448
442
449
static string DescribeCompilationError ( CompilerSerialInterface . LocatedCompilationError locatedCompilationError ) =>
450
+ "in file " + string . Join ( '/' , locatedCompilationError . location . filePath ) + ": " +
443
451
DescribeCompilationError ( locatedCompilationError . error ) ;
444
452
445
- static string DescribeCompilationError ( CompilerSerialInterface . CompilationError compilationError ) =>
446
- Newtonsoft . Json . JsonConvert . SerializeObject ( compilationError , Newtonsoft . Json . Formatting . Indented ) ;
453
+ static string DescribeCompilationError ( CompilerSerialInterface . CompilationError compilationError )
454
+ {
455
+ var otherCompilationError =
456
+ compilationError ? . OtherCompilationError ? . FirstOrDefault ( ) ;
457
+
458
+ if ( otherCompilationError != null )
459
+ return otherCompilationError ;
447
460
461
+ return
462
+ Newtonsoft . Json . JsonConvert . SerializeObject (
463
+ compilationError ,
464
+ Newtonsoft . Json . Formatting . Indented ,
465
+ new Newtonsoft . Json . JsonSerializerSettings
466
+ {
467
+ NullValueHandling = Newtonsoft . Json . NullValueHandling . Ignore ,
468
+ DefaultValueHandling = Newtonsoft . Json . DefaultValueHandling . Include
469
+ } ) ;
470
+ }
448
471
449
472
static long EstimateCacheItemSizeInMemory ( ElmValueCommonJson . Result < IReadOnlyList < CompilerSerialInterface . LocatedCompilationError > , ImmutableDictionary < IImmutableList < string > , IReadOnlyList < byte > > > item ) =>
450
473
( item . Err ? . Sum ( err => err . Sum ( EstimateCacheItemSizeInMemory ) ) ?? 0 ) +
0 commit comments