© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
12 replies
Bunda

❔ How to properly handle exceptions between API controller and service layer?

I'm creating an API and I'm having trouble figuring out how to properly catch errors between my service layer and controller. Could someone take a look at my current code and give me some advice? Useful docs or tutorials are also greatly appreciated.

To better understand the controller, this the controller route:
/api/v1/identity-users/{userRefId:guid}/risks
/api/v1/identity-users/{userRefId:guid}/risks


This is my current controller:
https://pastebin.com/Cg4CJ0QE

My service:
https://pastebin.com/KVaN3nYR
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

❔ Data Layer communicating ultimately to API controller
C#CC# / help
3y ago
Returning Service result to Controller (Minimal API)
C#CC# / help
17mo ago
✅ Polly retry - how to gracefully handle exceptions during retries
C#CC# / help
16mo ago
What should the service layer return back to a controller?
C#CC# / help
2y ago