mirror of
https://github.com/pockethost/pockethost.git
synced 2025-06-22 14:02:31 +00:00
chore: enhance error messaging
This commit is contained in:
parent
aee53e6143
commit
e948d7a2cc
@ -308,15 +308,15 @@ var HandleMigrateRegions = (e) => {
|
||||
var HandleInstanceBeforeUpdate = (e) => {
|
||||
const dao = e.dao || $app.dao();
|
||||
const log = mkLog(`instances-validate-before-update`);
|
||||
const id = e.model.getId();
|
||||
const version = e.model.get("version");
|
||||
if (!versions.includes(version)) {
|
||||
throw new BadRequestError(
|
||||
`Invalid version '${version}'. Version must be one of: ${versions.join(
|
||||
", "
|
||||
)}`
|
||||
);
|
||||
const msg = `[ERROR] Invalid version '${version}' for [${id}]. Version must be one of: ${versions.join(
|
||||
", "
|
||||
)}`;
|
||||
log(`${msg}`);
|
||||
throw new BadRequestError(msg);
|
||||
}
|
||||
const id = e.model.getId();
|
||||
const cname = e.model.get("cname");
|
||||
if (cname.length > 0) {
|
||||
const result = new DynamicModel({
|
||||
@ -333,7 +333,9 @@ var HandleInstanceBeforeUpdate = (e) => {
|
||||
return true;
|
||||
})();
|
||||
if (inUse) {
|
||||
throw new BadRequestError(`Custom domain already in use.`);
|
||||
const msg = `[ERROR] [${id}] Custom domain ${cname} already in use.`;
|
||||
log(`${msg}`);
|
||||
throw new BadRequestError(msg);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -1,4 +1,5 @@
|
||||
module.exports = [
|
||||
"0.23.*",
|
||||
"0.22.*",
|
||||
"0.21.*",
|
||||
"0.20.*",
|
||||
|
@ -6,16 +6,17 @@ export const HandleInstanceBeforeUpdate = (e: core.ModelEvent) => {
|
||||
|
||||
const log = mkLog(`instances-validate-before-update`)
|
||||
|
||||
const id = e.model.getId()
|
||||
|
||||
const version = e.model.get('version')
|
||||
if (!versions.includes(version)) {
|
||||
throw new BadRequestError(
|
||||
`Invalid version '${version}'. Version must be one of: ${versions.join(
|
||||
', ',
|
||||
)}`,
|
||||
)
|
||||
const msg = `[ERROR] Invalid version '${version}' for [${id}]. Version must be one of: ${versions.join(
|
||||
', ',
|
||||
)}`
|
||||
log(`${msg}`)
|
||||
throw new BadRequestError(msg)
|
||||
}
|
||||
|
||||
const id = e.model.getId()
|
||||
const cname = e.model.get('cname')
|
||||
if (cname.length > 0) {
|
||||
const result = new DynamicModel({
|
||||
@ -38,7 +39,9 @@ export const HandleInstanceBeforeUpdate = (e: core.ModelEvent) => {
|
||||
})()
|
||||
|
||||
if (inUse) {
|
||||
throw new BadRequestError(`Custom domain already in use.`)
|
||||
const msg = `[ERROR] [${id}] Custom domain ${cname} already in use.`
|
||||
log(`${msg}`)
|
||||
throw new BadRequestError(msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ export const instanceService = mkSingleton(
|
||||
dbg(`Updated instance fields`, fields)
|
||||
})
|
||||
.catch((e) => {
|
||||
error(`Error updating instance fields`, { fields, e })
|
||||
error(`Error updating instance fields for ${id}`, { fields, e })
|
||||
})
|
||||
},
|
||||
)
|
||||
@ -190,7 +190,7 @@ export const instanceService = mkSingleton(
|
||||
/** Health check */
|
||||
await tryFetch(`${internalUrl}/api/health`, {
|
||||
preflight: async () => {
|
||||
if (stopped()) throw new Error(`Container stopped`)
|
||||
if (stopped()) throw new Error(`Container stopped ${id}`)
|
||||
return started()
|
||||
},
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user