Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,11 @@ public Map<Path, TokenTree> generate() {
final Path collectionOfErrorsPath = Path.of("CollectionOfErrors.cs");
final TokenTree collectionOfErrorsPathCode =
generateCollectionExceptionClass();
final TokenTree genericImport = TokenTree.of("using System.Collections.Generic;");

codeByPath.put(
collectionOfErrorsPath,
collectionOfErrorsPathCode.prepend(prelude)
collectionOfErrorsPathCode.prepend(prelude).prepend(genericImport)
);

// Opaque exception class
Expand Down Expand Up @@ -329,9 +331,17 @@ public TokenTree generateCollectionExceptionClass() {
"""
public class CollectionOfErrors : Exception {
public readonly System.Collections.Generic.List<Exception> list;
public CollectionOfErrors(System.Collections.Generic.List<Exception> list, string message) : base(message) { this.list = list; }
public CollectionOfErrors(System.Collections.Generic.List<Exception> list, string message) : base(message + $"\\n List: \\n{ListAsString(list)}") { this.list = list; }
public CollectionOfErrors(string message) : base(message) { this.list = new System.Collections.Generic.List<Exception>(); }
public CollectionOfErrors() : base("CollectionOfErrors") { this.list = new System.Collections.Generic.List<Exception>(); }
private static string ListAsString(List<Exception> list)
{
if (list.Count < 1) return "";
string [] msgArr = new string [list.Count];
for (int i = 0; i < list.Count; i++)
msgArr[i] = $"{list[i].GetType().Name} :: {list[i].Message}";
return String.Join("\\n\\t", msgArr);
}
}
"""
)
Expand Down
Loading