mirror of
https://github.com/LukeHagar/plexjs.git
synced 2025-12-10 20:47:48 +00:00
ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.557.0
This commit is contained in:
@@ -2,41 +2,33 @@
|
||||
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
||||
*/
|
||||
|
||||
export class SDKError extends Error {
|
||||
/**
|
||||
* HTTP status code
|
||||
*/
|
||||
public readonly statusCode: number;
|
||||
/**
|
||||
* HTTP content type
|
||||
*/
|
||||
public readonly contentType: string;
|
||||
/**
|
||||
* HTTP body
|
||||
*/
|
||||
public readonly body: string;
|
||||
/**
|
||||
* Raw response
|
||||
*/
|
||||
public readonly rawResponse: Response;
|
||||
import { PlexAPIError } from "./plexapierror.js";
|
||||
|
||||
/** The fallback error class if no more specific error class is matched */
|
||||
export class SDKError extends PlexAPIError {
|
||||
constructor(
|
||||
message: string,
|
||||
rawResponse: Response,
|
||||
body: string = "",
|
||||
httpMeta: {
|
||||
response: Response;
|
||||
request: Request;
|
||||
body: string;
|
||||
},
|
||||
) {
|
||||
const statusCode = rawResponse.status;
|
||||
const contentType = rawResponse.headers.get("content-type") || "";
|
||||
const bodyString = body.length > 0 ? `\n${body}` : "";
|
||||
super(
|
||||
`${message}: Status ${statusCode} Content-Type ${contentType} Body ${bodyString}`,
|
||||
);
|
||||
|
||||
this.body = body;
|
||||
this.rawResponse = rawResponse;
|
||||
this.statusCode = statusCode;
|
||||
this.contentType = contentType;
|
||||
|
||||
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 = "SDKError";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user