postalcode-ws/postalcode

View on GitHub
src/utils/errors/PostalCodeError.ts

Summary

Maintainability
A
0 mins
Test Coverage
import { ServiceError } from "../../";

export interface PostalCodeError {
  message: string;
  type: string;
  country: string;
  errors: ServiceError[];
}

export class PostalCodeError extends Error {
  constructor({
    message,
    type,
    errors,
    country,
  }: {
    message: string;
    type: string;
    errors?: ServiceError[];
    country: string;
  }) {
    super();
    this.message = message;
    this.name = "PostalCodeError";
    this.type = type;
    this.country = country;
    if (errors) {
      this.errors = errors;
    }
  }
}

export default PostalCodeError;