Error Handling
Robust error handling is critical for ad playback on Smart TV platforms. This guide covers VAST error codes, recovery strategies, and graceful degradation patterns.Error Types
The SDK uses standardized VAST error codes defined insrc/types/vast.ts:208.
VASTErrorCode Enum
AdError Interface
Error structure is defined atsrc/types/player.ts:116:
Handling Errors
Using onError Callback
The simplest way to handle errors:Using Event Listeners
For more complex error handling:Error Categories
VAST Parsing Errors (100-199)
These occur during VAST XML parsing.XML_PARSING_ERROR (100)
- Malformed XML from ad server
- Network corruption
- Invalid UTF-8 encoding
VAST_SCHEMA_VALIDATION_ERROR (101)
- Missing
<Ad>element - Missing
<Impression>URLs - Invalid VAST structure
VAST_VERSION_NOT_SUPPORTED (102)
Wrapper Errors (300-399)
These occur when following VAST wrappers.GENERAL_WRAPPER_ERROR (300)
WRAPPER_TIMEOUT (301)
- Retry with increased timeout (15-20 seconds)
- Max 2-3 retries
- If still fails, skip ad
WRAPPER_LIMIT_REACHED (302)
maxWrapperDepth (default: 5)
Recovery: Not recoverable by design. Report to ad ops team.
NO_VAST_RESPONSE (303)
- No ad campaign available (no-fill)
- Geographic restrictions
- Frequency cap reached
Linear Creative Errors (400-499)
These occur during video playback.GENERAL_LINEAR_ERROR (400)
src/core/AdPlayer.ts:398
FILE_NOT_FOUND (401)
- VAST only has VPAID (not supported)
- No MP4/WebM files available
- All media files are unsupported codecs
src/core/AdPlayer.ts:129
Recovery: Not recoverable. Report to ad ops to add compatible media files.
MEDIA_TIMEOUT (402)
- Retry once after timeout
- If still fails, skip ad
- Log for CDN investigation
MEDIA_NOT_SUPPORTED (403)
src/core/AdPlayer.ts:220
Common causes:
- HEVC video on platform without HEVC support
- Corrupt video file
- DRM-protected content
Recovery Strategies
Strategy 1: Automatic Retry
Strategy 2: Fallback VAST URL
Strategy 3: Adaptive Timeout
Strategy 4: Error Tracking & Analytics
Common Error Scenarios
Scenario 1: Autoplay Blocked
Error:GENERAL_LINEAR_ERROR with message “Playback failed”
Cause: Browser/platform blocking autoplay
SDK Behavior: Automatically shows “Start Ad” overlay
User Action Required: Click play button
src/core/AdPlayer.ts:270-282
Scenario 2: Network Timeout
Error:WRAPPER_TIMEOUT or MEDIA_TIMEOUT
Cause: Slow network or unresponsive server
Recovery: Retry with longer timeout
Scenario 3: No Compatible Media
Error:FILE_NOT_FOUND
Cause: No suitable video format in VAST
Recovery: Not recoverable - report to ad ops
Scenario 4: Empty VAST Response
Error:NO_VAST_RESPONSE
Cause: No ad available (no-fill)
Recovery: Normal behavior - resume content
Graceful Degradation
Always ensure the user experience continues even when ads fail.Best Practice Pattern
Error Handling Checklist
- Always resume main content on ad error
- Never block user from watching content due to ad failure
- Log all errors to analytics for debugging
- Fire VAST error tracking pixels
- Clean up player resources with
destroy() - Implement retry logic for transient errors only
- Set reasonable timeout values (10-15 seconds)
- Test error scenarios on actual TV hardware
Next Steps
Configuration
Configure timeouts and error-related settings
Event Handling
Handle error events with listeners
Platform Detection
Handle platform-specific errors
Optimization
Prevent errors through optimization
