Skip to content

Commit

Permalink
Adding new error types and exporting them from module (#909)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpuri authored and MajorLift committed Oct 11, 2023
1 parent 63d005b commit 417484c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 2 deletions.
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

0 comments on commit 417484c

Please sign in to comment.