Error Handling
All SDK exceptions inherit from NetorcaBaseException, so you can catch everything with a single handler or handle specific cases individually.
Quick example
from netorca_sdk import NetOrcaClient
from netorca_sdk.exceptions import NetorcaAuthenticationError, NetorcaNotFoundError, NetorcaAPIError
try:
client = NetOrcaClient(fqdn="...", api_key="YOUR_API_KEY")
item = client.service_items.get(123)
except NetorcaAuthenticationError:
print("Invalid API key")
except NetorcaNotFoundError:
print("Resource not found")
except NetorcaAPIError as e:
print(f"API error: {e}")
Exception reference
| Exception | HTTP Status | When raised |
|---|---|---|
NetorcaAuthenticationError |
401 | API key is invalid or expired |
NetorcaNotFoundError |
404 | The requested resource does not exist |
NetorcaAPIError |
400 / 403 / 4xx / 5xx | Any other non-2xx API response (including access denied) |
NetorcaServerUnavailableError |
503 | NetOrca API is temporarily unavailable |
NetorcaGatewayError |
502 | Gateway or proxy error upstream of the API |
NetorcaTimeoutError |
— | Request exceeded the timeout limit |
NetorcaValueError |
— | Invalid value passed to an SDK method |
NetorcaPermissionError |
— | Permission denied (raised by application logic) |
NetorcaException |
— | General SDK usage error (bad input, missing config) |
NetorcaBaseException |
— | Base class — catches all of the above |
All exceptions can be imported from either netorca_sdk or netorca_sdk.exceptions:
# Both are equivalent
from netorca_sdk import NetorcaAuthenticationError
from netorca_sdk.exceptions import NetorcaAuthenticationError
Catching all SDK errors
from netorca_sdk.exceptions import NetorcaBaseException
try:
results = submission.submit()
except NetorcaBaseException as e:
print(f"NetOrca error: {e}")
sys.exit(1)
Handling submission errors
validate() and submit() do not raise exceptions on validation failures — they return (False, errors) instead. Exceptions are reserved for connectivity and authentication problems.