Generate Fern TypeSscript SDK (#3785)
This commit is contained in:
committed by
GitHub
parent
d55b9637c4
commit
2062adac66
53
skyvern-ts/client/src/errors/SkyvernError.ts
Normal file
53
skyvern-ts/client/src/errors/SkyvernError.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
// This file was auto-generated by Fern from our API Definition.
|
||||
|
||||
import type * as core from "../core/index.js";
|
||||
import { toJson } from "../core/json.js";
|
||||
|
||||
export class SkyvernError extends Error {
|
||||
public readonly statusCode?: number;
|
||||
public readonly body?: unknown;
|
||||
public readonly rawResponse?: core.RawResponse;
|
||||
|
||||
constructor({
|
||||
message,
|
||||
statusCode,
|
||||
body,
|
||||
rawResponse,
|
||||
}: {
|
||||
message?: string;
|
||||
statusCode?: number;
|
||||
body?: unknown;
|
||||
rawResponse?: core.RawResponse;
|
||||
}) {
|
||||
super(buildMessage({ message, statusCode, body }));
|
||||
Object.setPrototypeOf(this, SkyvernError.prototype);
|
||||
this.statusCode = statusCode;
|
||||
this.body = body;
|
||||
this.rawResponse = rawResponse;
|
||||
}
|
||||
}
|
||||
|
||||
function buildMessage({
|
||||
message,
|
||||
statusCode,
|
||||
body,
|
||||
}: {
|
||||
message: string | undefined;
|
||||
statusCode: number | undefined;
|
||||
body: unknown | undefined;
|
||||
}): string {
|
||||
const lines: string[] = [];
|
||||
if (message != null) {
|
||||
lines.push(message);
|
||||
}
|
||||
|
||||
if (statusCode != null) {
|
||||
lines.push(`Status code: ${statusCode.toString()}`);
|
||||
}
|
||||
|
||||
if (body != null) {
|
||||
lines.push(`Body: ${toJson(body, undefined, 2)}`);
|
||||
}
|
||||
|
||||
return lines.join("\n");
|
||||
}
|
||||
Reference in New Issue
Block a user