Skip to content

Commit 0b13c51

Browse files
committed
fix: improve error handling to re-throw non-Error exceptions
Signed-off-by: GitHub Copilot <noreply@github.com>
1 parent 076d1cf commit 0b13c51

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/internalEnforcer.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class InternalEnforcer extends CoreEnforcer {
3333
try {
3434
await this.adapter.addPolicy(sec, ptype, rule);
3535
} catch (e) {
36-
if (e instanceof Error && e.message !== 'not implemented') {
36+
if (!(e instanceof Error) || e.message !== 'not implemented') {
3737
throw e;
3838
}
3939
}
@@ -70,7 +70,7 @@ export class InternalEnforcer extends CoreEnforcer {
7070
try {
7171
await (this.adapter as BatchAdapter).addPolicies(sec, ptype, rules);
7272
} catch (e) {
73-
if (e instanceof Error && e.message !== 'not implemented') {
73+
if (!(e instanceof Error) || e.message !== 'not implemented') {
7474
throw e;
7575
}
7676
}
@@ -108,7 +108,7 @@ export class InternalEnforcer extends CoreEnforcer {
108108
try {
109109
await (this.adapter as UpdatableAdapter).updatePolicy(sec, ptype, oldRule, newRule);
110110
} catch (e) {
111-
if (e instanceof Error && e.message !== 'not implemented') {
111+
if (!(e instanceof Error) || e.message !== 'not implemented') {
112112
throw e;
113113
}
114114
}
@@ -144,7 +144,7 @@ export class InternalEnforcer extends CoreEnforcer {
144144
try {
145145
await this.adapter.removePolicy(sec, ptype, rule);
146146
} catch (e) {
147-
if (e instanceof Error && e.message !== 'not implemented') {
147+
if (!(e instanceof Error) || e.message !== 'not implemented') {
148148
throw e;
149149
}
150150
}
@@ -179,7 +179,7 @@ export class InternalEnforcer extends CoreEnforcer {
179179
try {
180180
await (this.adapter as BatchAdapter).removePolicies(sec, ptype, rules);
181181
} catch (e) {
182-
if (e instanceof Error && e.message !== 'not implemented') {
182+
if (!(e instanceof Error) || e.message !== 'not implemented') {
183183
throw e;
184184
}
185185
}
@@ -212,7 +212,7 @@ export class InternalEnforcer extends CoreEnforcer {
212212
try {
213213
await this.adapter.removeFilteredPolicy(sec, ptype, fieldIndex, ...fieldValues);
214214
} catch (e) {
215-
if (e instanceof Error && e.message !== 'not implemented') {
215+
if (!(e instanceof Error) || e.message !== 'not implemented') {
216216
throw e;
217217
}
218218
}

0 commit comments

Comments
 (0)