API
@agape/temporal

TemporalNotAvailableError Class

Error thrown when attempting to use Temporal functionality that is not available in the current environment.

API

class TemporalNotAvailableError extends Error {  constructor(message: string);  readonly message: string;  readonly name: string;  stack?: string;  static prepareStackTrace?: (    err: Error,    stackTraces: CallSite[]  ) => any;  static stackTraceLimit: number;  static captureStackTrace(targetObject: object, constructorOpt?: Function): void;}

constructor

TemporalNotAvailableError

Creates a new TemporalNotAvailableError instance.

@parammessage:  string
Custom error message. If not provided, a default message with helpful guidance about resolving the Temporal availability issue will be used.
@returnsTemporalNotAvailableError

message

string

The error message describing why Temporal is not available and how to resolve it. This message provides helpful guidance to developers about resolving the Temporal availability issue, including suggestions for polyfills and runtime requirements.

readonly

name

string

The name of the error. Always set to 'TemporalNotAvailableError'. This property identifies the specific type of error and is useful for error handling and debugging purposes.

readonly

stack

string

prepareStackTrace

object

Optional override for formatting stack traces

static

stackTraceLimit

number
static

captureStackTrace

void

Create .stack property on a target object

@paramtargetObject:  object
@paramconstructorOpt:  Function
@returnsvoid

Description

Error thrown when attempting to use Temporal functionality that is not available in the current environment.

This error is thrown by the stub implementations of Temporal classes when no Temporal implementation is available (neither native Temporal nor a polyfill). It provides helpful guidance on how to resolve the issue by suggesting polyfill options.

Usage

Produce an Error if no Temporal available

import { Temporal } from '@agape/temporal';

try {
  const date = Temporal.PlainDate.from('2025-09-19');
} catch (error) {
  if (error instanceof TemporalNotAvailableError) {
    console.error('Temporal is not available:', error.message);
    // Handle the error appropriately
  }
}

Resolve Error Using a Polyfill

// Using a polyfill to resolve the error
import { Temporal as TemporalPolyfill } from '@js-temporal/polyfill';
import { setTemporal } from '@agape/temporal';

// Set the polyfill
setTemporal(TemporalPolyfill);

// Now Temporal operations will work
const now = Temporal.PlainDateTime.from('2025-09-19T10:00');