File tree Expand file tree Collapse file tree 2 files changed +15
-9
lines changed Expand file tree Collapse file tree 2 files changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -304,13 +304,16 @@ export type ArangoApiResponse<T> = T & ArangoResponseMetadata;
304304/**
305305 * Indicates whether the given value represents an ArangoDB error response.
306306 */
307- export function isArangoErrorResponse ( body : any ) : body is ArangoErrorResponse {
308- if ( ! body || typeof body !== 'object' ) return false ;
307+ export function isArangoErrorResponse (
308+ body : unknown ,
309+ ) : body is ArangoErrorResponse {
310+ if ( ! body || typeof body !== "object" ) return false ;
311+ const obj = body as Record < string , unknown > ;
309312 return (
310- body . error === true &&
311- typeof body . code === 'number' &&
312- typeof body . errorMessage === 'string' &&
313- typeof body . errorNum === ' number'
313+ obj . error === true &&
314+ typeof obj . errorMessage === "string" &&
315+ typeof obj . errorNum === "number" &&
316+ ( obj . code === undefined || typeof obj . code === " number" )
314317 ) ;
315318}
316319
@@ -325,7 +328,7 @@ export type ArangoErrorResponse = {
325328 /**
326329 * Intended response status code as provided in the response body.
327330 */
328- code : number ;
331+ code ? : number ;
329332 /**
330333 * Error message as provided in the response body.
331334 */
Original file line number Diff line number Diff line change @@ -255,7 +255,7 @@ export class ArangoError extends Error {
255255 /**
256256 * HTTP status code included in the server error response object.
257257 */
258- code : number ;
258+ code ? : number ;
259259
260260 /**
261261 * @internal
@@ -271,7 +271,10 @@ export class ArangoError extends Error {
271271 /**
272272 * Creates a new `ArangoError` from an ArangoDB error response.
273273 */
274- constructor ( data : connection . ArangoErrorResponse , options : { cause ?: Error , isSafeToRetry ?: boolean | null } = { } ) {
274+ constructor (
275+ data : Omit < connection . ArangoErrorResponse , "error" > ,
276+ options : { cause ?: Error ; isSafeToRetry ?: boolean | null } = { } ,
277+ ) {
275278 const { isSafeToRetry, ...opts } = options ;
276279 super ( data . errorMessage , opts ) ;
277280 this . errorNum = data . errorNum ;
You can’t perform that action at this time.
0 commit comments