Skip to content

Commit fbacdce

Browse files
authored
chore: add response zod error (#77)
Signed-off-by: Timo Glastra <timo@animo.id>
1 parent 213f11d commit fbacdce

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { formatZodError } from '@openid4vc/utils'
12
import type { RetrieveCredentialsResponseNotOk } from '../credential-request/retrieve-credentials'
23
import { Openid4vciError } from './Openid4vciError'
34

@@ -7,8 +8,14 @@ export class Openid4vciRetrieveCredentialsError extends Openid4vciError {
78
public response: RetrieveCredentialsResponseNotOk,
89
responseText: string
910
) {
10-
super(
11-
`${message}\n${JSON.stringify(response.credentialResponseResult?.data ?? response.credentialErrorResponseResult?.data ?? responseText, null, 2)}`
12-
)
11+
const errorData =
12+
response.credentialResponseResult?.data ??
13+
response.credentialErrorResponseResult?.data ??
14+
(response.credentialResponseResult?.error
15+
? formatZodError(response.credentialResponseResult.error)
16+
: undefined) ??
17+
responseText
18+
19+
super(`${message}\n${JSON.stringify(errorData, null, 2)}`)
1320
}
1421
}

0 commit comments

Comments
 (0)