Broken example code in docs
I just wanted to implement custom error for validation and I've checked your docs, but found out that it's not working. I'm talking to:
public sealed class HttpError : Error
{
public HttpError(HttpStatusCode statusCode)
: base("An HTTP error occured.", ("StatusCode", statusCode))
{
}
}
Here's the base ctor receives tuple for status code, but this argument receives only IReadOnlyDictionary<string, object>. Tuple cannot be converted into dictionary
Link: https://jscarle.github.io/LightResults/docs/getting-started.html#custom-errors
Maybe add new constructor that receives those tuples with params keyword that will be converted to dictionary?
Something like:
public Error(string message, params (string key, object value)[] metadata) : this(message, metadata.ToDictionary(x => x.key, x => x.value))
Even better: Change IReadOnlyDictionary<string, object> into IEnumerable<KeyValuePair<string, object>> to allow passing arrays instead of dictionaries to reduce allocations
also same
@enricoroselino this package just don't updating. i migrated into ardalis' results instead. there is so much issues with this package. it's just don't ready to be used in production.
for example, pattern matching just don't work, because it has IsFailure/IsSuccess methods, instead of properties. To get value, you somehow need to call one of those methods and get value from out parameter. we have IActionableResult generic interface to instantiate result object instead of relying on reflection and this is great idea, but this just don't work, because you can't pass this into mediatr pipelines. mediatr just ignores this pipeline, because it can't match generic types. having better performance is not that worth than my headache with this package
v9.0.3 has been published which add this and other meta data overloads.