Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

feat: Add ResourceConflictError #74

Merged
merged 2 commits into from
Aug 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/errors/ResourceConflictError.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/

// eslint-disable-next-line import/prefer-default-export
export class ResourceConflictError extends Error {
readonly isResourceConflictError: boolean;

readonly resourceType: string;

readonly id: string;

constructor(resourceType: string, id: string, message?: string) {
const msg = message || `Resource ${resourceType}/${id} is conflicting`;
// Node Error class requires passing a string message to the parent class.
super(msg);
Object.setPrototypeOf(this, ResourceConflictError.prototype);
this.resourceType = resourceType;
this.id = id;
this.name = this.constructor.name;
this.isResourceConflictError = true;
}
}
export function isResourceConflictError(error: unknown): error is ResourceConflictError {
return Boolean(error) && (error as ResourceConflictError).isResourceConflictError === true;
}
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export * from './errors/ResourceVersionNotFoundError';
export * from './errors/UnauthorizedError';
export * from './errors/TooManyConcurrentExportRequestsError';
export * from './errors/InvalidSearchParameterError';
export * from './errors/ResourceConflictError';
export * from './validator';
export { makeLogger } from './loggerBuilder';
export { stubs } from './stubs';