ardalis / Result

A result abstraction that can be mapped to HTTP response codes if needed.
MIT License
847 stars 100 forks source link

Optional CorrelationId on ErrorList #181

Closed philipp985 closed 3 months ago

philipp985 commented 3 months ago

Would it be acceptable to change

public record ErrorList(IEnumerable<string> ErrorMessages, string? CorrelationId);

to

public record ErrorList(IEnumerable<string> ErrorMessages, string? CorrelationId = null);

By this it would be simpler to create an error. At least for my use case the correlationId is not needed and it is marked optional.

return Result.Error(new ErrorList(["My error"])

As an additional question or wish. I like to old approach to just return one error like this

return Result.Error("My error")

could this be added back?

ardalis commented 3 months ago

Agreed!