@docusign/iam-sdk
Version:
Developer-friendly & type-safe Typescript SDK specifically catered to leverage *@docusign/iam-sdk* API.
35 lines (32 loc) • 947 B
text/typescript
/*
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
*/
import { IamClientError } from "./iamclienterror.js";
/** The fallback error class if no more specific error class is matched */
export class APIError extends IamClientError {
constructor(
message: string,
httpMeta: {
response: Response;
request: Request;
body: string;
},
) {
if (message) {
message += `: `;
}
message += `Status ${httpMeta.response.status}`;
const contentType = httpMeta.response.headers.get("content-type") || `""`;
if (contentType !== "application/json") {
message += ` Content-Type ${
contentType.includes(" ") ? `"${contentType}"` : contentType
}`;
}
const body = httpMeta.body || `""`;
message += body.length > 100 ? "\n" : " ";
message += `Body ${body}`;
message = message.trim();
super(message, httpMeta);
this.name = "APIError";
}
}