Skip to content

Commit aa44aa9

Browse files
committed
fix: better error type
1 parent 06413c1 commit aa44aa9

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

lightweight/index.d.ts

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -184,22 +184,39 @@ export type HTTPResponseRaw = HTTPResponse & { body: ArrayBuffer }
184184

185185
export type MqlResponse = MqlPayload & { response: HTTPResponseWithBody }
186186

187-
export type MqlError = {
188-
code: string
189-
data?: MqlResponseData
187+
export type MqlOptions = MqlClientOptions & MicrolinkApiOptions
188+
189+
type MqlErrorGeneratedProps = {
190190
description: string
191-
headers: { [key: string]: string }
192-
message: string
193-
more: string
194191
name: string
192+
}
193+
194+
export type MqlError = {
195+
code: string
195196
status: MqlStatus
197+
message: string
198+
data?: MqlResponseData
199+
headers?: { [key: string]: string }
200+
more?: string
196201
statusCode?: number
197-
url: string
202+
url?: string
198203
}
199204

200-
export type MqlOptions = MqlClientOptions & MicrolinkApiOptions
205+
export type MqlErrorProps = MqlError & MqlErrorGeneratedProps
201206

202-
export const MicrolinkError: new (props: object) => MqlError
207+
export declare class MicrolinkError extends Error {
208+
constructor(props: MqlError)
209+
readonly code: string
210+
readonly status: MqlStatus
211+
readonly message: string
212+
readonly description: string
213+
readonly name: string
214+
readonly data?: MqlResponseData
215+
readonly headers?: { [key: string]: string }
216+
readonly more?: string
217+
readonly statusCode?: number
218+
readonly url?: string
219+
}
203220

204221
export const version: string
205222

0 commit comments

Comments
 (0)