© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
6 replies
UltraWelfare

Tips on error handling

I'm currently using OneOf to handle errors.

For example:

public async Task<OneOf<None, NotFound, List<ValidationFailure>, GenericError>> EditOrderItem(Guid uid, EditOrderItemOptions options)
public async Task<OneOf<None, NotFound, List<ValidationFailure>, GenericError>> EditOrderItem(Guid uid, EditOrderItemOptions options)

However that is kinda of mouthful. I could try to refactor it using OneOfBase, but there are cases where I need <None, NotFound> or <None, NotFound, GenericError> or really any combination...

Is there any way I can refactor it?
I'd like to avoid exceptions as this would migrate the problem to "try-catching" everything then `if - is" on the exceptions
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ MVC Error Handling
C#CC# / help
3y ago
HttpRequestException Error Handling
C#CC# / help
4y ago
✅ Error handling in C#
C#CC# / help
13mo ago
Tips on paths to follow
C#CC# / help
7mo ago