handle

fnauto handle(E : Throwable, RangePrimitive primitivesToHandle, alias handler, Range)(Range input) if (isInputRange!Range)

Handle exceptions thrown from range primitives.

Use the RangePrimitive enum to specify which primitives to _handle. Multiple range primitives can be handled at once by using the OR operator or the pseudo-primitives RangePrimitive.access and RangePrimitive.pop. All handled primitives must have return types or values compatible with the user-supplied handler.

Parameters

EThe type of Throwable to _handle.
primitivesToHandleSet of range primitives to _handle.
handlerThe callable that is called when a handled primitive throws a Throwable of type E. The handler must accept arguments of the form E, ref IRange and its return value is used as the primitive's return value whenever E is thrown. For opIndex, the handler can optionally recieve a third argument; the index that caused the exception.
inputThe range to _handle.

Returns

A wrapper struct that preserves the range interface of input.

Note

Infinite ranges with slicing support must return an instance of Take when sliced with a specific lower and upper

bound (see hasSlicing); handle deals with this by takeing 0 from the return value of the handler function and returning that when an exception is caught.