Skip to content

Commit a52bce2

Browse files
feat: add isInvalidArgument type guard to ServiceError
1 parent d3306e0 commit a52bce2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

arduino-ide-extension/src/node/service-error.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ export namespace ServiceError {
2121
return is(arg) && arg.code === 1; // https://grpc.github.io/grpc/core/md_doc_statuscodes.html
2222
}
2323

24+
export function isInvalidArgument(
25+
arg: unknown
26+
): arg is ServiceError & { code: StatusCode.INVALID_ARGUMENT } {
27+
return is(arg) && arg.code === 3; // https://grpc.github.io/grpc/core/md_doc_statuscodes.html
28+
}
29+
2430
export function is(arg: unknown): arg is ServiceError {
2531
return arg instanceof Error && isStatusObject(arg);
2632
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy