apps-script-utils 2.1.1 Help

requireRepository

function requireRepository<T>( repository: T | null | undefined, message: string = "Repository is not defined." ): T;

requireService for the layer above the services: a data source that a container was supposed to provide and did not. The exception names the situation instead of leaving a null to travel further.

Parameters

Parameter

Type

Description

repository

T \| null \| undefined

The repository to check.

message (optional) = "Repository is not defined."

string

The message of the exception. A default is used when omitted.

Returns

T — the same repository.

Throws

Exception

Condition

RepositoryIsNotDefinedException

the repository is null or undefined.

Examples

In use

const users = requireRepository(registry.users, "The user repository is not wired up.");

See also

Source

src/appsscript/requireRepository.ts

23 September 2026

This documentation was generated with AI (Claude) from the library's source code.