mirror of
https://github.com/pockethost/pockethost.git
synced 2026-03-05 16:48:47 +00:00
enh: improve version error information
This commit is contained in:
@@ -6,9 +6,12 @@
|
||||
onModelBeforeCreate((e) => {
|
||||
const { versions } = require(`${__hooks}/versions.pb.js`)
|
||||
|
||||
if (!versions.includes(e.model.get('version'))) {
|
||||
const version = e.model.get('version')
|
||||
if (!versions.includes(version)) {
|
||||
throw new BadRequestError(
|
||||
`'version' must be one of: ${versions.join(', ')}`,
|
||||
`Invalid version ${version}. Version must be one of: ${versions.join(
|
||||
', ',
|
||||
)}`,
|
||||
)
|
||||
}
|
||||
}, 'instances')
|
||||
|
||||
@@ -6,9 +6,12 @@
|
||||
onModelBeforeUpdate((e) => {
|
||||
const { versions } = require(`${__hooks}/versions.pb.js`)
|
||||
|
||||
if (!versions.includes(e.model.get('version'))) {
|
||||
const version = e.model.get('version')
|
||||
if (!versions.includes(version)) {
|
||||
throw new BadRequestError(
|
||||
`'version' must be one of: ${versions.join(', ')}`,
|
||||
`Invalid version ${version}. Version must be one of: ${versions.join(
|
||||
', ',
|
||||
)}`,
|
||||
)
|
||||
}
|
||||
}, 'instances')
|
||||
|
||||
Reference in New Issue
Block a user