Skip to content

Commit

Permalink
Types cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
bidoubiwa committed Sep 2, 2020
1 parent 4928c8f commit f91e25a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 24 deletions.
21 changes: 3 additions & 18 deletions src/errors/meilisearch-api-error.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,7 @@
import * as Types from '../types'

export type MSApiErrorConstructor = new (
error: MSApiError,
status: number
) => void

export interface MSApiError extends Error {
name: string
message: string
stack?: string
httpStatus: number
errorCode?: string
errorType?: string
errorLink?: string
}

const MeiliSearchApiError: MSApiErrorConstructor = class extends Error
implements Types.MeiliSearchApiErrorInterface {
const MeiliSearchApiError: Types.MSApiErrorConstructor = class extends Error
implements Types.MSApiError {
httpStatus: number
response?: Types.MeiliSearchApiErrorResponse
errorCode?: string
Expand All @@ -25,7 +10,7 @@ const MeiliSearchApiError: MSApiErrorConstructor = class extends Error
stack?: string
type: string

constructor(error: MSApiError, status: number) {
constructor(error: Types.MSApiError, status: number) {
super(error.message)
this.type = 'MeiliSearchApiError'
this.name = 'MeiliSearchApiError'
Expand Down
19 changes: 13 additions & 6 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,18 +327,25 @@ export interface MeiliSearchApiErrorRequest {
method?: string
}


export interface FetchError extends Error {
type: string
errno: string
code: string
}

export interface HttpConfig extends Request {
params?: { [key: string]: any }
export type MSApiErrorConstructor = new (
error: MSApiError,
status: number
) => void

export interface MSApiError extends Error {
name: string
message: string
stack?: string
httpStatus: number
errorCode?: string
errorType?: string
errorLink?: string
}
// export interface HttpResponse<T> extends Response {
// parsedBody?: T
// }

export default MeiliSearch

0 comments on commit f91e25a

Please sign in to comment.