phonic
Version:
[](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2FPhonic-Co%2Fphonic-node) [ • 1.06 kB
JavaScript
// This file was auto-generated by Fern from our API Definition.
import * as errors from "./index.mjs";
export function handleNonStatusCodeError(error, rawResponse, method, path) {
switch (error.reason) {
case "non-json":
throw new errors.PhonicError({
statusCode: error.statusCode,
body: error.rawBody,
rawResponse: rawResponse,
});
case "body-is-null":
throw new errors.PhonicError({
statusCode: error.statusCode,
rawResponse: rawResponse,
});
case "timeout":
throw new errors.PhonicTimeoutError(`Timeout exceeded when calling ${method} ${path}.`);
case "unknown":
throw new errors.PhonicError({
message: error.errorMessage,
rawResponse: rawResponse,
});
default:
throw new errors.PhonicError({
message: "Unknown error",
rawResponse: rawResponse,
});
}
}