mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
handle errors during policy instantiation
This commit is contained in:
parent
0589728b16
commit
ebbe2b86d9
1 changed files with 11 additions and 1 deletions
|
|
@ -8,6 +8,7 @@ import * as Comlink from 'comlink';
|
||||||
import { ReadOnlySigner } from '@/signers/ReadOnlySigner.ts';
|
import { ReadOnlySigner } from '@/signers/ReadOnlySigner.ts';
|
||||||
import { DittoPgStore } from '@/storages/DittoPgStore.ts';
|
import { DittoPgStore } from '@/storages/DittoPgStore.ts';
|
||||||
import { DEFAULT_POLICY_SPEC, PolicySpec } from '@/utils/policies.ts';
|
import { DEFAULT_POLICY_SPEC, PolicySpec } from '@/utils/policies.ts';
|
||||||
|
import { logi } from '@soapbox/logi';
|
||||||
|
|
||||||
// @ts-ignore Don't try to access the env from this worker.
|
// @ts-ignore Don't try to access the env from this worker.
|
||||||
Deno.env = new Map<string, string>();
|
Deno.env = new Map<string, string>();
|
||||||
|
|
@ -75,8 +76,17 @@ export class CustomPolicy implements NPolicy {
|
||||||
for (const item of spec.policies) {
|
for (const item of spec.policies) {
|
||||||
const policy = registry.available[item.name];
|
const policy = registry.available[item.name];
|
||||||
if (!policy) continue;
|
if (!policy) continue;
|
||||||
|
try {
|
||||||
policies.push(policy.instantiate(item.params || {}));
|
policies.push(policy.instantiate(item.params || {}));
|
||||||
}
|
}
|
||||||
|
catch (e) {
|
||||||
|
logi({
|
||||||
|
level: 'error',
|
||||||
|
ns: 'ditto.system.policy.worker',
|
||||||
|
msg: `Error instantiating policy ${item.name} with params \`${JSON.stringify(item.params)}\`: ${e}`
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.policy = new PipePolicy(policies);
|
this.policy = new PipePolicy(policies);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue