Skip to main content

Errors

Petrominds uses conventional HTTP response codes to indicate the success or failure of an API request. Codes in the 2xx range indicate success. Codes in the 4xx range indicate an error with the provided information. Codes in the 5xx range indicate a server error.

HTTP Status Codes​

CodeStatusDescription
200OKRequest succeeded
400Bad RequestUnable to compute results with provided parameters
401UnauthorizedAPI key is missing or invalid
403ForbiddenAccess denied
422Unprocessable EntityThe request body failed validation
429Too Many RequestsRate limit exceeded
500Internal Server ErrorSomething went wrong on our end

Error Response Format​

All errors return a JSON object with the following attributes:

message string

A human-readable message providing details about the error.

errorCode string

A short string indicating the error type. Useful for programmatic handling.

errors object or null

For validation errors, contains field-specific error messages. The keys are field names and values are arrays of error messages. For other error types, this field is null.

Error Codes​

Error CodeHTTP StatusDescription
CALCULATION_ERROR400Unable to compute results with the provided parameters
INVALID_API_KEY401API key is invalid, expired, or suspended
UNAUTHORIZED401API key is missing from the request
FORBIDDEN403Access denied
VALIDATION_ERROR422Request parameters failed validation rules
RATE_LIMIT_EXCEEDED429Too many requests in a given time period
ERROR500General server error

Examples​

Missing API Key​

{
"message": "Access denied due to missing subscription key. Make sure to include subscription key when making requests to this API",
"errorCode": "UNAUTHORIZED",
"errors": null
}

Invalid API Key​

{
"message": "Access denied due to invalid subscription key. Make sure to provide a valid key for an active subscription",
"errorCode": "INVALID_API_KEY",
"errors": null
}

Forbidden​

{
"message": "Access denied",
"errorCode": "FORBIDDEN",
"errors": null
}

Rate Limit Exceeded​

{
"message": "Rate limit exceeded",
"errorCode": "RATE_LIMIT_EXCEEDED",
"errors": null
}

Validation Error​

{
"message": "One or more validation errors occurred",
"errorCode": "VALIDATION_ERROR",
"errors": {
"Tr": ["Reservoir Temperature must be greater than 0"],
"Pb": ["Bubble Point Pressure is required"]
}
}

Calculation Error​

{
"message": "Unable to perform calculation with provided parameters",
"errorCode": "CALCULATION_ERROR",
"errors": null
}

Handling Errors in SDKs​

Each SDK raises typed exceptions for error responses instead of returning raw JSON. Catch the most specific exception first and re-throw anything unexpected. The examples below use QAMind — the same pattern applies to every SDK; replace the namespace and client exception class with the one for your service.

import { QAMindClient, QAMind } from "@petrominds/qa-mind";

const client = new QAMindClient({ apiKey: "YOUR_API_KEY" });

try {
const result = await client.qa.calculate({
/* ... */
});

console.log(result);
} catch (error) {
if (error instanceof QAMind.UnauthorizedError) {
console.error("Invalid API key.");

} else if (error instanceof QAMind.UnprocessableEntityError) {
console.error(`Validation error: ${error.body?.errorCode}`);

for (const [field, messages] of Object.entries(error.body?.errors ?? {})) {
console.error(` ${field}: ${messages.join(", ")}`);
}

} else if (error instanceof QAMind.BadRequestError) {
console.error(`Calculation error: ${error.body?.message}`);

} else if (error instanceof QAMind.TooManyRequestsError) {
console.error("Rate limit exceeded — back off and retry.");

} else {
throw error;
}
}