Error Code
5 min
error response format when a request fails, the external api returns the appropriate http status code and a json body of the shape { "message" "vault has insufficient balance to complete the transaction", "code" "4003" } field description message human readable description of what went wrong code machine readable error code present for known errors (see the reference below) falls back to "400" for generic validation failures, and may be absent for a few low level errors tip branch your logic on code where a specific code exists how the sdks surface errors sdks raise a typed error per http status (e g badrequesterror for 400 , forbiddenerror for 403 , toomanyrequestserror for 429 ) typescript / javascript the error carries message , errorcode , status , and responsetext import { badrequesterror } from "@primevault/js api sdk"; try { await apiclient createtransfertransaction({ source, destination, amount, asset, chain }); } catch (error) { if (error instanceof badrequesterror) { switch (error errorcode) { case "4003" / insufficient balance / break; case "4011" / compliance / ofac blocked / break; case "4013" / invalid transaction parameters / break; default / fall back to error message / break; } } } python the error carries response text (the message) and code from primevault python sdk base api client import badrequesterror try api client create transfer transaction(request) except badrequesterror as e if e code == "4003" # insufficient balance elif e code == "4011" # compliance / ofac blocked else # fall back to e response text