Skip to main content

Error format

Shoplazza CLI uses structured JSON error envelopes on stderr for consistent error handling.

Error envelope

{
"error": {
"type": "api",
"message": "Product not found",
"hint": "Check the product ID and try again"
},
"request_id": "req_abc123"
}

Error types

TypeExit codeDescription
api1Shoplazza API returned an error response
validation2Invalid CLI input (missing flags, bad format)
auth3Authentication failure (expired token, missing scope)
network4Network connectivity issue
internal5Unexpected CLI error

Fields

FieldTypeDescription
error.typestringOne of the 5 error types above
error.messagestringHuman-readable error description
error.hintstringActionable suggestion for resolving the error
request_idstringRequest ID for debugging (API errors only)

Handling errors programmatically

# Capture stderr for error details
output=$(shoplazza products get --id 999 2>&1)
exit_code=$?

if [ $exit_code -ne 0 ]; then
echo "$output" | jq -r '.error.hint'
fi

stdout vs stderr

  • stdout — Success data only (JSON envelopes with "ok": true)
  • stderr — Errors, progress indicators, warnings, and hints

This separation ensures you can safely pipe stdout without corruption:

shoplazza products list --jq '.data.products[].id' | while read id; do
shoplazza products get --id "$id"
done