JoBrad/http-json-errors

Wrong title when is not filled

clabnet opened this issue · 1 comments

When you create an error without specifyng the title :

 const successResult = createError(200, {
      message: 'Success',
      body: {
        code: 'OK',
        level: ErrorLevelEnum.INFO
      }
    })

the title attribute contain the wrong text Internal Server Error

  isHttpError: true,
  statusCode: 200,
  title: "Internal Server Error",
  message: "Success",
  body: {
    code: "OK",
    level: "info",
  },
  status: 200,

The library only has pre-filled values for status codes >= 400. You're getting the default value for title because your status code is below that. Try the same code but with a 401, to see what I mean.