Reader small image

You're reading from  Hands-On Microservices with Django

Product typeBook
Published inMay 2024
PublisherPackt
ISBN-139781835468524
Edition1st Edition
Right arrow
Author (1)
Tieme Woldman
Tieme Woldman
author image
Tieme Woldman

Tieme Woldman works as a freelance Python developer and technical writer. As a Python developer, he builds web and data engineering applications with Django and Python data transformation packages such as pandas. As a technical writer, he has written software and user documentation for software companies such as Instruqt, Noldus Information Technology, and Rulecube. Tieme lives in the Netherlands, has a bachelor's degree in computer science, and holds several (technical) writing certifications.
Read more about Tieme Woldman

Right arrow

Error handling

Clients will make mistakes or send invalid data when sending requests, and our RESTful API needs to catch them and inform the client about what went wrong to enable the client to anticipate accordingly. The client-server communication for a DRF-based RESTful API in case of an error generally covers these steps:

  1. The client sends a request to an endpoint.
  2. The RESTful API at the endpoint parses the request.
  3. The URL mechanism and the serializer in the RESTful API validate the request and catch an error.
  4. The RESTful API sends an error message and a corresponding HTTP status code back to the client.
  5. The client parses the request.
  6. The client signals the error and catches it with alternate processing.

To implement the RESTful API part in this process, we need to handle possible errors, which falls apart in the following areas:

  • Handling wrong formatted requests, such as a missing data object, when creating new data through a POST request...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Hands-On Microservices with Django
Published in: May 2024Publisher: PacktISBN-13: 9781835468524

Author (1)

author image
Tieme Woldman

Tieme Woldman works as a freelance Python developer and technical writer. As a Python developer, he builds web and data engineering applications with Django and Python data transformation packages such as pandas. As a technical writer, he has written software and user documentation for software companies such as Instruqt, Noldus Information Technology, and Rulecube. Tieme lives in the Netherlands, has a bachelor's degree in computer science, and holds several (technical) writing certifications.
Read more about Tieme Woldman