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:API Response Errors
API Response Errors
Errors returned from the Falcon API in the
errors property of the response.From /home/daytona/workspace/source/private/Private.ps1:1328-1340:Parameter Validation Errors
Parameter Validation Errors
Errors from invalid parameter values, patterns, or combinations.
FQL (Falcon Query Language) Errors
FQL (Falcon Query Language) Errors
Validation errors for malformed filter expressions.From
/home/daytona/workspace/source/private/Private.ps1:1182-1197:Runtime Errors
Runtime Errors
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_iderrors- Array of error objectsresources- 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:/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:
Available ErrorAction Values
Available ErrorAction Values
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:/home/daytona/workspace/source/private/Private.ps1:1366-1370, all operations log to the verbose stream:
Trace IDs
Every API response includes atrace_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
Authentication Errors
Authentication Errors
invalid_client- Invalid ClientId or ClientSecretMissing required credentials- ClientId/ClientSecret not providedno_access_request_made- Token required but not available
Validation Errors
Validation Errors
ParameterArgumentValidationError- Parameter doesn’t match required patternnot a valid Falcon Query Language statement- Invalid FQL syntaxMissing required property- Object missing required fields
Runtime Errors
Runtime Errors
Aborted due to missing pagination token- Pagination interruptedFailed 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