HTTP errors
HTTP status codes and the two error shapes.
Status codes
Code
Meaning
Common cause
Two error shapes
// HTTP-level failure (400, 404, 500, …)
{ "error": "descriptive message" }
// Compute failure returned inside a 200 body (quote endpoints)
{ "err": "descriptive message" }Handling pattern
const res = await fetch(`${FLASH_API_URL}/transaction-builder/open-position`, {
method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(req),
});
if (!res.ok) {
const { error } = await res.json(); // 4xx / 5xx
if (res.status === 404) console.error("Market or symbol not found");
if (res.status === 503) console.error("Price unavailable (market closed?)");
throw new Error(error);
}
const data = await res.json();
if (data.err) throw new Error(data.err); // compute error in a 200 body
// else sign & submit data.transactionBase64Last updated
Was this helpful?

