-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
111 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
"codecov", | ||
"connectrpc", | ||
"displaystatemap", | ||
"instanceof", | ||
"keyof", | ||
"morty", | ||
"njwt", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -471,6 +471,23 @@ Get an object instance with the type `type-name` and the id `object-id`. For exa | |
|
||
```typescript | ||
const user = await directoryClient.object({ objectType: 'user', objectId: '[email protected]' }); | ||
|
||
// Handle a not found object | ||
import { NotFoundError } from "@aserto/aserto-node" | ||
|
||
try { | ||
directoryClient.object({ | ||
objectType: "user", | ||
objectId: "[email protected]", | ||
}); | ||
} catch (error) { | ||
if (error instanceof NotFoundError) { | ||
// pass trough | ||
} | ||
|
||
// throw back the original error | ||
throw error; | ||
} | ||
``` | ||
|
||
#### 'relation' function | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -234,7 +234,7 @@ describe("DirectoryV3", () => { | |
it("handles ConnectError", async () => { | ||
const mockCheckPermission = jest | ||
.spyOn(directory.ReaderClient, "checkPermission") | ||
.mockRejectedValue(new ConnectError("connect error", 5)); | ||
.mockRejectedValue(new ConnectError("connect error", 1)); | ||
|
||
const params = { | ||
subjectId: "[email protected]", | ||
|
@@ -244,7 +244,7 @@ describe("DirectoryV3", () => { | |
objectId: "admin", | ||
}; | ||
await expect(directory.checkPermission(params)).rejects.toThrow( | ||
'"checkPermission" failed with code: 5, message: [not_found] connect error' | ||
'"checkPermission" failed with code: 1, message: [canceled] connect error' | ||
); | ||
|
||
mockCheckPermission.mockReset(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* Object or Relation is not found. | ||
* Extends the built-in Error class. | ||
* | ||
* @class NotFoundError | ||
* @extends Error | ||
*/ | ||
export class NotFoundError extends Error {} | ||
/** | ||
* "Invalid Argument" error. | ||
* Extends the built-in Error class. | ||
* | ||
* @class InvalidArgumentError | ||
* @extends Error | ||
*/ | ||
export class InvalidArgumentError extends Error {} | ||
/** | ||
* "Etag Mismatch" error. | ||
* Extends the built-in Error class. | ||
* | ||
* @class EtagMismatchError | ||
* @extends Error | ||
*/ | ||
export class EtagMismatchError extends Error {} | ||
/** | ||
* "Unauthenticated" error. | ||
* Extends the built-in Error class. | ||
* | ||
* @class EtagMismatchError | ||
* @extends Error | ||
*/ | ||
export class UnauthenticatedError extends Error {} | ||
export class ServiceError extends Error {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,3 +58,5 @@ export { | |
SubIdentityMapper, | ||
DirectoryConfig as ServiceConfig, | ||
}; | ||
|
||
export * from "./directory/errors"; |