Is there a way to return custom objects similar to a .Success response. ardalis result

133 Views Asked by At

I've been attempting to return a custom object with a 'Error' status, but I'm facing difficulties in implementing it.

Success return looks like this

return Result<customObject>.Success(customObject);

However, I would like the code to resemble this instead:

return Result<customObject>.Error(customObject);

The issue I'm encountering is that the object passed to Error cannot be converted to a 'string'. Is there a way to do it the same way with return success?

0

There are 0 best solutions below