makeomatic/ms-payments

View on GitHub
src/utils/paypal/agreements/error/status.js

Summary

Maintainability
A
0 mins
Test Coverage
const CODE_AGREEMENT_STATUS_FORBIDDEN = 'agreement-status-forbidden';

class AgreementStatusError extends Error {
  constructor(agreementId, owner, status, creatorTaskId, token) {
    super(`Agreement "${agreementId}" has status "${status}"`);

    this.code = CODE_AGREEMENT_STATUS_FORBIDDEN;
    this.params = { agreementId, owner, status, creatorTaskId, token };
  }

  getHookErrorData() {
    return {
      message: this.message,
      code: this.code,
      params: this.params,
    };
  }
}

module.exports = {
  AgreementStatusError,
};