Skip to content

Instantly share code, notes, and snippets.

@victorjonsson
Created November 16, 2018 10:32
Show Gist options
  • Save victorjonsson/ecd1146b427e65c66daca8b500fcc104 to your computer and use it in GitHub Desktop.
Save victorjonsson/ecd1146b427e65c66daca8b500fcc104 to your computer and use it in GitHub Desktop.
public SomethingController([FromBody] MyDataModel model) {
try {
DoTheStuff(model);
} catch (SpecificExceptionIKnowCanHappen exc) {
return BadRequest(new { errorCode = ErrorCode });
}
// all other exceptions will let the app crash, exception info will be sen to log and app returns status 500 to the client
return Ok();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment