mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 03:19: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 { DittoPgStore } from '@/storages/DittoPgStore.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.
|
||||
Deno.env = new Map<string, string>();
|
||||
|
|
@ -75,7 +76,16 @@ export class CustomPolicy implements NPolicy {
|
|||
for (const item of spec.policies) {
|
||||
const policy = registry.available[item.name];
|
||||
if (!policy) continue;
|
||||
policies.push(policy.instantiate(item.params || {}));
|
||||
try {
|
||||
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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue