diff --git a/src/domain/entities/generic/Either.ts b/src/domain/entities/generic/Either.ts index ecca6888..adff2c62 100644 --- a/src/domain/entities/generic/Either.ts +++ b/src/domain/entities/generic/Either.ts @@ -17,11 +17,9 @@ export class Either { constructor(public value: EitherValue) {} - getOrThrow(): Data | undefined { - if (this.isError()) { - throw this.value.error; - } - return this.value.data; + getOrThrow(): Data { + if (this.value.data) return this.value.data; + else throw this.value.error; } match(matchObj: MatchObject): Res {