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

Diff for: arduino-ide-extension/src/node/service-error.ts

+6
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)