Skip to main content

Overview

PSFalcon provides comprehensive error handling for API responses, parameter validation, and runtime exceptions. Errors are written to PowerShell’s error stream with detailed context to help troubleshoot issues.

Error Types

PSFalcon handles several types of errors:
Errors returned from the Falcon API in the errors property of the response.From /home/daytona/workspace/source/private/Private.ps1:1328-1340:
Errors from invalid parameter values, patterns, or combinations.
Validation errors for malformed filter expressions.From /home/daytona/workspace/source/private/Private.ps1:1182-1197:
Errors from missing dependencies, network issues, or unexpected conditions.

API Error Responses

From /home/daytona/workspace/source/private/Private.ps1:1307-1365, PSFalcon’s Write-Result function processes API responses:
1

Response Processing

Every API response is parsed for:
  • meta - Metadata including pagination and trace_id
  • errors - Array of error objects
  • resources - The actual data payload
2

Error Extraction

If errors are present in the response:
3

Error Stream Output

Errors are written to PowerShell’s error stream using $PSCmdlet.WriteError().This allows you to:
  • Catch errors with try/catch
  • Suppress errors with -ErrorAction
  • Access error details in $Error[0]

Handling API Errors

Using Try/Catch

Using ErrorAction

Checking Error Details

Parameter Validation

PSFalcon validates parameters before making API requests:

FQL Validation

Falcon Query Language (FQL) statements are validated before submission:
From /home/daytona/workspace/source/private/Private.ps1:1186-1188, the FQL pattern is:
FQL validation is a client-side check. The API may return additional validation errors for semantically invalid queries.

Error Action Preference

Control error behavior using PowerShell’s -ErrorAction parameter:

Common Error Scenarios

Authentication Errors

Rate Limiting

From /home/daytona/workspace/source/public/oauth2.ps1:194-196, PSFalcon automatically retries on rate limit (429) responses:

Missing Resources

Pagination Errors

From /home/daytona/workspace/source/private/Private.ps1:658-660:

Logging and Debugging

Verbose Output

Enable verbose logging to see detailed request/response information:
From /home/daytona/workspace/source/private/Private.ps1:1366-1370, all operations log to the verbose stream:

Trace IDs

Every API response includes a trace_id for troubleshooting:

WhatIf Support

Many PSFalcon commands support -WhatIf to preview actions:

Best Practices

1

Always Use Try/Catch for Critical Operations

2

Validate Results

3

Log Error Details for Troubleshooting

4

Handle Partial Results

Error Reference

  • invalid_client - Invalid ClientId or ClientSecret
  • Missing required credentials - ClientId/ClientSecret not provided
  • no_access_request_made - Token required but not available
  • ParameterArgumentValidationError - Parameter doesn’t match required pattern
  • not a valid Falcon Query Language statement - Invalid FQL syntax
  • Missing required property - Object missing required fields
  • Aborted due to missing pagination token - Pagination interrupted
  • Failed to initialize [ApiClient] object - Client initialization failed
  • HTTP 429 - Rate limit exceeded (automatically retried)

Next Steps

Pagination

Learn how PSFalcon handles large result sets automatically

Filtering

Master FQL syntax for precise queries