mirror of
https://github.com/pockethost/pockethost.git
synced 2025-06-22 22:12:32 +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) => {
|
var HandleInstanceBeforeUpdate = (e) => {
|
||||||
const dao = e.dao || $app.dao();
|
const dao = e.dao || $app.dao();
|
||||||
const log = mkLog(`instances-validate-before-update`);
|
const log = mkLog(`instances-validate-before-update`);
|
||||||
|
const id = e.model.getId();
|
||||||
const version = e.model.get("version");
|
const version = e.model.get("version");
|
||||||
if (!versions.includes(version)) {
|
if (!versions.includes(version)) {
|
||||||
throw new BadRequestError(
|
const msg = `[ERROR] Invalid version '${version}' for [${id}]. Version must be one of: ${versions.join(
|
||||||
`Invalid version '${version}'. Version must be one of: ${versions.join(
|
", "
|
||||||
", "
|
)}`;
|
||||||
)}`
|
log(`${msg}`);
|
||||||
);
|
throw new BadRequestError(msg);
|
||||||
}
|
}
|
||||||
const id = e.model.getId();
|
|
||||||
const cname = e.model.get("cname");
|
const cname = e.model.get("cname");
|
||||||
if (cname.length > 0) {
|
if (cname.length > 0) {
|
||||||
const result = new DynamicModel({
|
const result = new DynamicModel({
|
||||||
@ -333,7 +333,9 @@ var HandleInstanceBeforeUpdate = (e) => {
|
|||||||
return true;
|
return true;
|
||||||
})();
|
})();
|
||||||
if (inUse) {
|
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 = [
|
module.exports = [
|
||||||
|
"0.23.*",
|
||||||
"0.22.*",
|
"0.22.*",
|
||||||
"0.21.*",
|
"0.21.*",
|
||||||
"0.20.*",
|
"0.20.*",
|
||||||
|
@ -6,16 +6,17 @@ export const HandleInstanceBeforeUpdate = (e: core.ModelEvent) => {
|
|||||||
|
|
||||||
const log = mkLog(`instances-validate-before-update`)
|
const log = mkLog(`instances-validate-before-update`)
|
||||||
|
|
||||||
|
const id = e.model.getId()
|
||||||
|
|
||||||
const version = e.model.get('version')
|
const version = e.model.get('version')
|
||||||
if (!versions.includes(version)) {
|
if (!versions.includes(version)) {
|
||||||
throw new BadRequestError(
|
const msg = `[ERROR] Invalid version '${version}' for [${id}]. Version must be one of: ${versions.join(
|
||||||
`Invalid version '${version}'. Version must be one of: ${versions.join(
|
', ',
|
||||||
', ',
|
)}`
|
||||||
)}`,
|
log(`${msg}`)
|
||||||
)
|
throw new BadRequestError(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
const id = e.model.getId()
|
|
||||||
const cname = e.model.get('cname')
|
const cname = e.model.get('cname')
|
||||||
if (cname.length > 0) {
|
if (cname.length > 0) {
|
||||||
const result = new DynamicModel({
|
const result = new DynamicModel({
|
||||||
@ -38,7 +39,9 @@ export const HandleInstanceBeforeUpdate = (e: core.ModelEvent) => {
|
|||||||
})()
|
})()
|
||||||
|
|
||||||
if (inUse) {
|
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)
|
dbg(`Updated instance fields`, fields)
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.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 */
|
/** Health check */
|
||||||
await tryFetch(`${internalUrl}/api/health`, {
|
await tryFetch(`${internalUrl}/api/health`, {
|
||||||
preflight: async () => {
|
preflight: async () => {
|
||||||
if (stopped()) throw new Error(`Container stopped`)
|
if (stopped()) throw new Error(`Container stopped ${id}`)
|
||||||
return started()
|
return started()
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user