Navigation

It’s very common to implement RESTful APIs on top of Flask. One of the
first things that developers run into is the realization that the builtin
exceptions are not expressive enough for APIs and that the content type of
text/html they are emitting is not very useful for API consumers.

The better solution than using abort to signal errors for invalid API
usage is to implement your own exception type and install an error handler
for it that produces the errors in the format the user is expecting.

At that point views can raise that error, but it would immediately result
in an internal server error. The reason for this is that there is no
handler registered for this error class. That however is easy to add: