What is the error handling status code of koa for web requests?

I would like to ask if there is any middleware that reports an error, or how to deal with these states. Beginner koa writes several interfaces, but I don"t quite understand how to return the status code returned to the front end according to the error

.
200400403
Apr.02,2021

take the article system as an example

  1. everything is fine
  2. not logged in to 401
  3. logs in, but does not have permission, such as deleting articles that are not self-published
  4. API parameters are mispassed 400
  5. the requested article does not exist
Menu