-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from Cyber4All/main
Main -> Releases
- Loading branch information
Showing
8 changed files
with
244 additions
and
41 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
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
node_modules | ||
/lib | ||
/coverage | ||
/coverage | ||
/reports |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,8 +1,88 @@ | ||
|
||
export interface ValidationErrorOptions { | ||
/** | ||
* The shape ID name of the exception. | ||
*/ | ||
readonly name: string; | ||
/** | ||
* Whether the client or server are at fault. | ||
*/ | ||
readonly $fault: "client" | "server"; | ||
|
||
/** | ||
* The error message. | ||
*/ | ||
readonly message: string; | ||
} | ||
|
||
/** | ||
* @public | ||
* | ||
* Base error class for the exceptions from the validation acl package. | ||
*/ | ||
export class ValidationError extends Error{ | ||
readonly $fault: "client" | "server"; | ||
constructor(options: ValidationErrorOptions) { | ||
super(options.message); | ||
this.name = options.name; | ||
this.$fault = options.$fault; | ||
} | ||
} | ||
|
||
// The following example demonstrates why it is beneficial to use a custom error class | ||
// rather than using the built-in Error class and check for the error name. | ||
// https://aws.amazon.com/blogs/developer/service-error-handling-modular-aws-sdk-js/ | ||
|
||
/** | ||
* The action did not match the REGEX pattern to validate the formatting of the ACL string. | ||
* | ||
* @public | ||
*/ | ||
export class ActionMismatchError extends ValidationError { | ||
/** | ||
* @internal | ||
*/ | ||
constructor(message?: string) { | ||
super({ | ||
name: "ActionMismatchError", | ||
$fault: "client", | ||
message, | ||
}); | ||
} | ||
} | ||
|
||
/** | ||
* The service defined in the ACL string is not supported by the package. | ||
* | ||
* @public | ||
*/ | ||
export class ServiceNotSupportedError extends ValidationError { | ||
/** | ||
* @internal | ||
*/ | ||
constructor(message?: string) { | ||
super({ | ||
name: "ServiceNotSupportedError", | ||
$fault: "client", | ||
message, | ||
}); | ||
} | ||
} | ||
|
||
/** | ||
* Error thrown when there is a validation issue with acls | ||
* The action being validated is not supported by the package. | ||
* | ||
* @public | ||
*/ | ||
export class ValidationError extends Error { | ||
constructor(msg: string) { | ||
super(msg); | ||
export class ActionNotSupportedError extends ValidationError { | ||
/** | ||
* @internal | ||
*/ | ||
constructor(message?: string) { | ||
super({ | ||
name: "ActionNotSupportedError", | ||
$fault: "client", | ||
message, | ||
}); | ||
} | ||
} |
Oops, something went wrong.