Error Handling

  • When your @XMapping method throws an exception, Spring sends back an error HTTP response
  • You can control what error codes and info get sent back for specific errors
  • Sometimes you want to throw specific exceptions when something is unexpected
  • There are a number of ways to do this
  • Different approaches have different benefits
  • One easy approach is to throw a ResponseStatusException

15 / 31