Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding new error types and exporting them from module #909

Merged
merged 1 commit into from
Sep 15, 2022
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
3 changes: 2 additions & 1 deletion src/approval/ApprovalController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { nanoid } from 'nanoid';

import { BaseController, Json } from '../BaseControllerV2';
import type { RestrictedControllerMessenger } from '../ControllerMessenger';
import { ApprovalRequestNotFoundError } from './errors';

const controllerName = 'ApprovalController';

Expand Down Expand Up @@ -568,7 +569,7 @@ export class ApprovalController extends BaseController<
private _deleteApprovalAndGetCallbacks(id: string): ApprovalCallbacks {
const callbacks = this._approvals.get(id);
if (!callbacks) {
throw new Error(`Approval request with id '${id}' not found.`);
throw new ApprovalRequestNotFoundError(id);
}

this._delete(id);
Expand Down
5 changes: 5 additions & 0 deletions src/approval/errors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export class ApprovalRequestNotFoundError extends Error {
constructor(id: string) {
super(`Approval request with id '${id}' not found.`);
}
}
2 changes: 2 additions & 0 deletions src/approval/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './ApprovalController';
export * from './errors';
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { formatIconUrlWithProxy } from './assets/assetsUtil';

export * from './assets/AccountTrackerController';
export * from './user/AddressBookController';
export * from './approval/ApprovalController';
export * from './approval';
export * from './assets/AssetsContractController';
export * from './BaseController';
export {
Expand Down
1 change: 1 addition & 0 deletions src/permissions/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from './Caveat';
export * from './errors';
export * from './Permission';
export * from './PermissionController';
export * from './utils';
Expand Down