All files / errors Generic.error.ts

22.22% Statements 2/9
0% Branches 0/8
0% Functions 0/1
22.22% Lines 2/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27          5x         5x                                
import { AxiosError } from 'axios'
import * as _ from 'lodash'
import { IErrors } from '.'
import { RateLimitDto } from '../models-dto/rate-limit/rate-limit.dto'
 
const message = 'Generic error'
 
/**
 * Not api key found
 */
export class GenericError extends Error implements IErrors {
  readonly status: number
  readonly error: Error
  readonly rateLimits: RateLimitDto
  readonly body?: any
  readonly name = 'GenericError'
 
  constructor (rateLimits: RateLimitDto, error: AxiosError) {
    super(error.message || message)
    this.status = error.response!.status
    this.body = error.response?.data || null;
    this.rateLimits = rateLimits
    this.error = error
    Object.setPrototypeOf(this, GenericError.prototype)
  }
}