All files / utils ErrorTypes.ts

71.42% Statements 20/28
44.44% Branches 4/9
71.42% Functions 10/14
71.42% Lines 20/28

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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108        24x 24x 24x           13x           3x             5x           3x               18x 18x 18x               18x 18x 18x                         1x 1x                                         3x 3x 3x                         2x 2x          
import logger from "./logger";
 
export class MyError extends Error {
  constructor(message: string, name: string) {
    super(message);
    this.name = name;
    logger.error(`${this.name}: ${this.message}`);
  }
}
 
export class InvalidEntityError extends MyError {
  constructor(message: string) {
    super(message, "InvalidEntityError");
  }
}
 
export class InvalidArgumentError extends MyError {
  constructor(message: string) {
    super(message, "InvalidArgumentError");
  }
}
 
 
export class EmptyStorageError extends MyError {
  constructor(message: string) {
    super(message, "EmptyStorageError");
  }
}
 
export class LocationAccessError extends MyError {
  constructor(message: string) {
    super(message, "LocationAccessError");
  }
}
 
export class PDFDownloadError extends Error {
  product_id: number;
 
  constructor(product_id: number, message = "Unable to download PDF. ") {
    super(message);
    this.name = "PDFDownloadError";
    this.product_id = product_id;
  }
}
 
export class PDFUpdateError extends Error {
  product_id: number;
 
  constructor(product_id: number, message = "Unable to update PDF.") {
    super(message);
    this.name = "PDFUpdateError";
    this.product_id = product_id;
  }
}
 
export class VaccineUpdateError extends Error {
  constructor(message = "Unable to update PDF.") {
    super(message);
    this.name = "VaccineUpdateError";
  }
}
 
export class VaccineListVersionError extends Error {
  constructor(message = "Remote list version behind local version") {
    super(message);
    this.name = "VaccineListVersionError";
  }
}
 
export class VaccineSearchError extends Error {
    constructor(message = "Problem searching for vaccines") {
      super(message);
      this.name = "VaccineSearchError";
    }
  }
 
export class NoInternetError extends Error {
  constructor(message = "No internet connection. Please try again later.") {
    super(message);
    this.name = "NoInternetError";
  }
}
 
  export class FetchError extends Error {
    url: string;
    constructor(url: string, message = "Problem pulling data from URL") {
      super(message);
      this.name = "FetchError";
      this.url = url;
    }
  }
 
  export class FactQueryError extends Error {
    constructor(message = "Unable to get fact") {
      super(message);
      this.name = "FactQueryError";
    }
  }
 
  export class RemoteFactError extends Error {
    constructor(message = "Problem getting the remote list of facts") {
      super(message);
      this.name = "RemoteFactError";
    }
  }