globalMOO Documentation
  • globalMOO API Documentation
  • core
    • Authentication
    • Core Concepts
    • Getting Started with globalMOO
    • Error Handling
    • Event Handling
    • SDK Initialization
    • Debugging & Logging
  • schemas
    • Account Schema
    • Model Schema
    • Project Schema
    • Trial Schema
    • Objective Schema
    • Result Schema
    • Inverse Schema
  • quickstart
    • Your First Optimization with globalMOO
  • endpoints
    • accounts
      • Account Endpoints
      • Register Account
    • inverse
      • Inverse Optimization Endpoints
      • Initialize Inverse Optimization
      • Load Inverse Output
      • Suggest Inverse Step
    • models
      • Create Model
      • Model Endpoints
      • List Models
    • objectives
      • Objective Endpoints
      • Load Objectives
    • outputs
      • Output Endpoints
      • Load Output Cases
      • Load Developed Outputs
    • projects
      • Create Project
      • Project Endpoints
    • trials
      • Trial Endpoints
      • Read Trial
Powered by GitBook
On this page
  • Error Types
  • Error Response Format
  • Validation Rules
  • Input Arrays
  • Numeric Values
  • Types & Categories
  • Timestamps
  • SDK Error Handling Example
  • Best Practices
  1. core

Error Handling

The globalMOO API and SDKs provide structured error handling and validation across all operations.

Error Types

  1. InvalidArgumentException

    • Thrown when invalid arguments are provided to SDK methods

    • Common causes: invalid array lengths, wrong data types, missing required fields

  2. InvalidRequestException

    • Thrown when the API rejects a request

    • Includes HTTP status code and detailed error messages

    • Contains validation errors for specific fields

  3. InvalidResponseException

    • Thrown when response data cannot be properly decoded

    • Indicates potential API version mismatch or malformed response

  4. NetworkConnectionException

    • Thrown when network communication fails

    • Includes retry count and timing information

Error Response Format

API error responses follow this structure:

{
    "status": 400,
    "title": "Validation Error",
    "message": "The request parameters were invalid.",
    "errors": [
        {
            "property": "fieldName",
            "message": "Detailed validation message"
        }
    ]
}

Validation Rules

Input Arrays

  • Array lengths must match specified counts

  • All numeric values must be valid integers or floats

  • Arrays must not be null or undefined

Numeric Values

  • Input minimums must be less than maximums

  • L1 norm values must be non-negative

  • Integer inputs must be whole numbers

Types & Categories

  • Input types must match enumerated values

  • Category arrays required for categorical inputs

  • Boolean values must be 0 or 1

Timestamps

  • All timestamps must be valid ISO 8601 format

  • Future timestamps not allowed

  • Optional timestamps can be null

SDK Error Handling Example

from globalmoo.exceptions import (
    InvalidArgumentException,
    InvalidRequestException,
    InvalidResponseException,
    NetworkConnectionException
)

try:
    client.create_project(
        model_id=model.id,
        input_count=3,
        minimums=[0.0, 0.0, 0.0],
        maximums=[1.0, 1.0, 1.0],
        input_types=["float", "float", "float"]
    )
except InvalidArgumentException as e:
    print(f"Invalid arguments: {e}")
except InvalidRequestException as e:
    print(f"API rejected request: {e.status} - {e.message}")
    for error in e.errors:
        print(f"  {error['property']}: {error['message']}")
except InvalidResponseException as e:
    print(f"Invalid response: {e}")
except NetworkConnectionException as e:
    print(f"Network error: {e}")

Best Practices

  1. Always use try-catch blocks around API calls

  2. Check array lengths before making requests

  3. Validate input types match requirements

  4. Handle network errors with retries

  5. Log detailed error information

  6. Use proper type hints/contracts

  7. Validate all input data before sending

PreviousGetting Started with globalMOONextEvent Handling

Last updated 3 months ago