slack-web-api-client
Version:
Streamlined Slack Web API client for TypeScript
66 lines • 2.28 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.WebhookError = exports.TokenRotationError = exports.SlackAPIError = exports.SlackAPIConnectionError = void 0;
class SlackAPIConnectionError extends Error {
apiName;
status;
body;
headers;
cause;
constructor(apiName, status, body, headers, cause) {
const substring = body.replaceAll("\r", "").replaceAll("\n", "").substring(0, 100);
const bodyToPrint = substring.length === 1000 ? substring + " ..." : substring;
const message = cause !== undefined
? `Failed to call ${apiName} (cause: ${cause})`
: `Failed to call ${apiName} (status: ${status}, body: ${bodyToPrint})`;
super(message);
this.name = "SlackAPIConnectionError";
this.apiName = apiName;
this.status = status;
this.body = body;
this.headers = headers;
this.cause = cause;
}
}
exports.SlackAPIConnectionError = SlackAPIConnectionError;
class SlackAPIError extends Error {
apiName;
error;
result;
constructor(apiName, error, result) {
const resultToPrint = JSON.stringify(result);
const message = `Failed to call ${apiName} due to ${error}: ${resultToPrint}`;
super(message);
this.name = "SlackAPIError";
this.apiName = apiName;
this.error = error;
this.result = result;
}
}
exports.SlackAPIError = SlackAPIError;
class TokenRotationError extends Error {
cause;
constructor(message, cause) {
super(message);
this.name = "TokenRotationError";
this.cause = cause;
}
}
exports.TokenRotationError = TokenRotationError;
class WebhookError extends Error {
status;
body;
cause;
constructor(status, body, cause = undefined) {
const message = cause
? `Failed to send a message using incoming webhook/response_url (cause: ${cause})`
: `Failed to send a message using incoming webhook/response_url (status: ${status}, body: ${body})`;
super(message);
this.name = "WebhookError";
this.status = status;
this.body = body;
this.cause = cause;
}
}
exports.WebhookError = WebhookError;
//# sourceMappingURL=errors.js.map