Err<T, E>
Represents an error result containing an error value.
Sinceβ
2.0.0
Type Parametersβ
T: Tβ
The type of the success value (unused in Err)
E: Eβ
The type of the error value
Implementsβ
IResult<T,E>
Constructorsβ
Constructorβ
Creates a new Err result.
error:
Eβ The error value to wrap
Returns:Err<T, E>
Propertiesβ
error: Eβ
The error value to wrap
Methodsβ
isOk()β
Always returns false for Err instances.
Returns: this is Ok<T, E>β
false
Implementation of: IResult.isOkβ
isErr()β
Always returns true for Err instances. Optimized to return the constant value directly.
Returns: this is Err<T, E>β
true
Implementation of: IResult.isErrβ
map()β
No-op for Err instances - the value transformation function is ignored.
Type Parametersβ
A: Aβ
The type of the transformed value (unused)
_f:
(t) => Aβ Transformation function (ignored)
Returns:Result<A, E>β A new Err result with the original error
Implementation of: IResult.mapβ
mapErr()β
Transforms the error value using the provided function.
Type Parametersβ
U: Uβ
The type of the transformed error
f:
(e) => Uβ Function to transform the error value
Returns:Result<T, U>β A new Err result with the transformed error
Implementation of: IResult.mapErrβ
andThen()β
Call Signatureβ
No-op for Err instances - the chaining function is ignored.
Type Parametersβ
R: R extends Result<unknown, unknown>β
The type of the Result returned by the function (unused)
_f:
(t) => Rβ Chaining function (ignored)
Returns:Result<InferOkTypes<R>, E | InferErrTypes<R>>β A new Err result with the original error
Implementation of: IResult.andThenβ
Call Signatureβ
No-op for Err instances with explicit type parameters.
Type Parametersβ
U: Uβ
The type of the success value in the returned Result (unused)
F: Fβ
The type of the error value in the returned Result (unused)
_f:
(t) => Result<U, F>β Chaining function (ignored)
Returns:Result<U, E | F>β A new Err result with the original error
Implementation of: IResult.andThenβ
unwrapOr()β
Always returns the default value for Err instances.
Type Parametersβ
A: Aβ
The type of the default value
v:
Aβ Default value to return
Returns:T | Aβ The default value
Implementation of: IResult.unwrapOrβ
match()β
Executes the error function with the error value.
Type Parametersβ
A: Aβ
The return type for the success case (unused)
B: B = Aβ
The return type for the error case
_ok:
(t) => Aβ Success function (ignored)
err:(e) => Bβ Function to execute with the error value
Returns:A | Bβ The result of executing the error function
Implementation ofβ
IResult.match