Skip to content

Commit ae4aff0

Browse files
committed
fix(keto-client-wrapper): enhance error handling for Axios errors in mock controller
1 parent 7c7ef46 commit ae4aff0

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

packages/keto-client-wrapper/test/app.controller.mock.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import {
33
Controller,
44
ForbiddenException,
55
Get,
6-
Logger,
76
Param,
87
UseGuards,
98
} from '@nestjs/common';
9+
import { isAxiosError } from 'axios';
1010
import { inspect } from 'node:util';
1111

1212
import { OryAuthorizationGuard } from '../src/lib/ory-authorization.guard';
@@ -16,11 +16,19 @@ import { ExampleService } from './app.service.mock';
1616
const AuthorizationGuard = () =>
1717
OryAuthorizationGuard({
1818
postCheck(result) {
19-
Logger.log('relationTuple', result.results);
20-
Logger.log('isPermitted', result.allowed);
19+
console.warn('evalation results', result.results);
20+
console.warn('isPermitted', result.allowed);
2121
},
2222
unauthorizedFactory(ctx, error) {
23-
console.error(inspect((error as any).error.response, false, null, true));
23+
const axiosError =
24+
typeof error === 'object' &&
25+
error &&
26+
'error' in error &&
27+
isAxiosError(error.error)
28+
? error.error
29+
: null;
30+
if (axiosError)
31+
console.error(inspect(axiosError.cause, false, null, true));
2432
return new ForbiddenException();
2533
},
2634
});

0 commit comments

Comments
 (0)