@@ -152,7 +152,14 @@ IImmutableDictionary<IImmutableList<string>, IReadOnlyList<byte>> compileNew()
152152 var otherErrorsText =
153153 string . Join ( "\n " , otherErrors . Select ( DescribeCompilationError ) ) ;
154154
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 " ) ;
156163 }
157164
158165 byte [ ] ElmMake (
@@ -440,11 +447,27 @@ static byte[] GetManifestResourceStreamContent(string name)
440447 }
441448
442449 static string DescribeCompilationError ( CompilerSerialInterface . LocatedCompilationError locatedCompilationError ) =>
450+ "in file " + string . Join ( '/' , locatedCompilationError . location . filePath ) + ": " +
443451 DescribeCompilationError ( locatedCompilationError . error ) ;
444452
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 ;
447460
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+ }
448471
449472 static long EstimateCacheItemSizeInMemory ( ElmValueCommonJson . Result < IReadOnlyList < CompilerSerialInterface . LocatedCompilationError > , ImmutableDictionary < IImmutableList < string > , IReadOnlyList < byte > > > item ) =>
450473 ( item . Err ? . Sum ( err => err . Sum ( EstimateCacheItemSizeInMemory ) ) ?? 0 ) +
0 commit comments