From b1b8465b46fdf81c94cb501b1b0d2937ef4c6dd1 Mon Sep 17 00:00:00 2001 From: azabroflovski Date: Fri, 13 May 2022 20:35:46 +0500 Subject: [PATCH] feat: add MXIK unknown exception --- src/exceptions/index.ts | 9 +++++++++ src/lib/index.ts | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 src/exceptions/index.ts diff --git a/src/exceptions/index.ts b/src/exceptions/index.ts new file mode 100644 index 0000000..ad9efee --- /dev/null +++ b/src/exceptions/index.ts @@ -0,0 +1,9 @@ +/** + * Handle MXIK unknown exceptions + */ +export class MXIKUnknownException extends Error { + constructor(message: any) { + super(message) + this.name = 'NotFoundException' + } +} \ No newline at end of file diff --git a/src/lib/index.ts b/src/lib/index.ts index c0bd11c..29205ed 100644 --- a/src/lib/index.ts +++ b/src/lib/index.ts @@ -1,5 +1,6 @@ import { MXIKSearchSymbol } from '../api' import { MXIKSearchOptionsObj, MXIKSearchResponseObj } from '../typings' +import { MXIKUnknownException } from '../exceptions' /** * Search items by keyword @@ -22,6 +23,6 @@ export async function MXIKSearch(keyword: string, { limit }: MXIKSearchOptionsOb } } } catch (error) { - throw error + throw new MXIKUnknownException('Something wrong') } }