Skip to content

Commit

Permalink
New: adds basic errors
Browse files Browse the repository at this point in the history
  • Loading branch information
pustovitDmytro committed Apr 23, 2021
1 parent 96e14a1 commit beefa3d
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/Error.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
export default class SemanticReleaseHerokuError extends Error {
#payload;

constructor(payload) {
super();

this.name = this.constructor.name;
this.#payload = payload;

Error.captureStackTrace(this, this.constructor);
}

get payload() {
return this.#payload;
}
}

export class VERIFICATION_MISSED extends SemanticReleaseHerokuError {
message = `verifyConditions should be passed to run step [${this.payload}]`
}

export class VALIDATION_FAILED extends SemanticReleaseHerokuError {
message = JSON.stringify(this.payload)
}

export class API_ERROR extends SemanticReleaseHerokuError {
get message() {
const message = this.payload.toString();
const inner = this.payload?.response?.data;

if (inner) return [ message, JSON.stringify(inner) ].join(' ');

return message;
}
}

0 comments on commit beefa3d

Please sign in to comment.