Skip to main content

HeliosError

Custom error class for all Helios-specific errors.
export class HeliosError extends Error {
  public readonly code: HeliosErrorCode;
  public readonly suggestion?: string;

  constructor(code: HeliosErrorCode, message: string, suggestion?: string)
}
code
HeliosErrorCode
required
Error code identifying the specific error type
message
string
required
Human-readable error message
suggestion
string
Optional suggestion for resolving the error

Properties

code
HeliosErrorCode
The error code identifying the specific error type
suggestion
string | undefined
Optional suggestion for resolving the error

Static methods

isHeliosError

Type guard to check if an unknown error is a HeliosError.
static isHeliosError(error: unknown): error is HeliosError
error
unknown
required
Error to check
return
boolean
True if the error is a HeliosError instance

Example

import { HeliosError, HeliosErrorCode } from '@helios-project/core';

try {
  // Some operation that might fail
  throw new HeliosError(
    HeliosErrorCode.INVALID_FPS,
    'FPS must be greater than 0',
    'Use a positive number for fps'
  );
} catch (error) {
  if (HeliosError.isHeliosError(error)) {
    console.error(`Error [${error.code}]: ${error.message}`);
    if (error.suggestion) {
      console.log(`Suggestion: ${error.suggestion}`);
    }
  }
}

HeliosErrorCode

Enumeration of all possible error codes in Helios.
enum HeliosErrorCode {
  INVALID_DURATION = 'INVALID_DURATION',
  INVALID_FPS = 'INVALID_FPS',
  INVALID_PLAYBACK_RANGE = 'INVALID_PLAYBACK_RANGE',
  INVALID_INPUT_RANGE = 'INVALID_INPUT_RANGE',
  INVALID_OUTPUT_RANGE = 'INVALID_OUTPUT_RANGE',
  UNSORTED_INPUT_RANGE = 'UNSORTED_INPUT_RANGE',
  INVALID_SPRING_CONFIG = 'INVALID_SPRING_CONFIG',
  INVALID_SRT_FORMAT = 'INVALID_SRT_FORMAT',
  INVALID_WEBVTT_FORMAT = 'INVALID_WEBVTT_FORMAT',
  INVALID_INPUT_PROPS = 'INVALID_INPUT_PROPS',
  INVALID_RESOLUTION = 'INVALID_RESOLUTION',
  INVALID_COLOR_FORMAT = 'INVALID_COLOR_FORMAT',
  INVALID_TIMECODE_FORMAT = 'INVALID_TIMECODE_FORMAT',
  INVALID_MARKER = 'INVALID_MARKER',
  MARKER_NOT_FOUND = 'MARKER_NOT_FOUND',
  INVALID_SCHEMA = 'INVALID_SCHEMA'
}

Error codes

INVALID_DURATION
Duration value is invalid or out of acceptable range
INVALID_FPS
Frames per second value is invalid (e.g., zero or negative)
INVALID_PLAYBACK_RANGE
Playback range is invalid or malformed
INVALID_INPUT_RANGE
Input range for interpolation is invalid
INVALID_OUTPUT_RANGE
Output range for interpolation is invalid
UNSORTED_INPUT_RANGE
Input range values are not in strictly ascending order
INVALID_SPRING_CONFIG
Spring animation configuration is invalid
INVALID_SRT_FORMAT
SRT subtitle format is malformed
INVALID_WEBVTT_FORMAT
WebVTT subtitle format is malformed
INVALID_INPUT_PROPS
Component input props failed validation
INVALID_RESOLUTION
Resolution value is invalid
INVALID_COLOR_FORMAT
Color string format is not recognized
INVALID_TIMECODE_FORMAT
Timecode format does not match HH:MM:SS:FF
INVALID_MARKER
Marker definition is invalid
MARKER_NOT_FOUND
Requested marker does not exist
INVALID_SCHEMA
Schema definition is invalid or malformed