Move humanizeErrors to errors service file

This commit is contained in:
Sean King 2025-02-08 19:26:29 -07:00
parent f659c9c123
commit 2af00f7c7e
No known key found for this signature in database
GPG key ID: 510C52BACD6E7257
3 changed files with 11 additions and 12 deletions

View file

View file

@ -1,11 +0,0 @@
import { capitalize } from 'lodash'
export function humanizeErrors (errors) {
return Object.entries(errors).reduce((errs, [k, val]) => {
const message = val.reduce((acc, message) => {
const key = capitalize(k.replace(/_/g, ' '))
return acc + [key, message].join(' ') + '. '
}, '')
return [...errs, message]
}, [])
}

View file

@ -1,4 +1,14 @@
import { humanizeErrors } from '../../modules/errors'
import { capitalize } from 'lodash'
function humanizeErrors (errors) {
return Object.entries(errors).reduce((errs, [k, val]) => {
const message = val.reduce((acc, message) => {
const key = capitalize(k.replace(/_/g, ' '))
return acc + [key, message].join(' ') + '. '
}, '')
return [...errs, message]
}, [])
}
export function StatusCodeError (statusCode, body, options, response) {
this.name = 'StatusCodeError'