| 68956 | }; |
| 68957 | var APIError = class _APIError extends AnthropicError { |
| 68958 | constructor(status, error, message, headers) { |
| 68959 | super(`${_APIError.makeMessage(status, error, message)}`); |
| 68960 | this.status = status; |
| 68961 | this.headers = headers; |
| 68962 | this.error = error; |
| 68963 | } |
| 68964 | static makeMessage(status, error, message) { |
| 68965 | const msg = error?.message ? typeof error.message === "string" ? error.message : JSON.stringify(error.message) : error ? JSON.stringify(error) : message; |
| 68966 | if (status && msg) { |
| 68967 | return `${status} ${msg}`; |
| 68968 | } |
| 68969 | if (status) { |
| 68970 | return `${status} status code (no body)`; |
| 68971 | } |
| 68972 | if (msg) { |
| 68973 | return msg; |