1

I am using Loopback4 to build REST APIs that can communicate directly with native mobile apps. As part f the error handling process what I need to do is formulating a standard error response with the following structure:

{
  code (Error code),
  errorName (Error Name),
  description (detailed description of the error)
} 

This object will be sent to the native app in case any error occurs.

Salitha
  • 1,022
  • 1
  • 12
  • 32
user3004499
  • 189
  • 3

1 Answers1

0

import {HttpErrors} from '@loopback/rest'

then

throw new HttpError[code](message) or throw new HttpErrors.Forbidden('Invalid authorization');

see more here on documentation

Salitha
  • 1,022
  • 1
  • 12
  • 32