Error messages

We have a well-defined error handler, as we saw in the previous section, so we can now write meaningful error messages that will help you with troubleshooting and make sure that sensitive information is not exposed.

Error messages will depend on the type of application you are coding for. As an example, think about what kind of error message you would like to see to help you solve an issue or understand what is happening.

We will apply some ideas and you can then go further and improve the error messages for the order-api application.

First, we will change the order.ts controller file, as follows:

import { NextFunction, Request, Response } from 'express'import * as halson from 'halson'import * as _ from 'lodash'import { OrderModel ...

Get Hands-On RESTful Web Services with TypeScript 3 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.