fix(architecture): fix execute method on error handler. (#38)
This commit is contained in:
parent
37d9ab748d
commit
8bb0dbb6b7
@ -43,9 +43,8 @@ abstract class UseCase<Parameters, ReturnType>
|
|||||||
/// Supports the result of the main scenario and integrates
|
/// Supports the result of the main scenario and integrates
|
||||||
/// some alternative scenarios if necessary.
|
/// some alternative scenarios if necessary.
|
||||||
@override
|
@override
|
||||||
FutureOrResult<ReturnType> execute(Parameters? parameters) =>
|
FutureOrResult<ReturnType> execute(Parameters? parameters) async {
|
||||||
Result.tryCatchAsync(
|
try {
|
||||||
() async {
|
|
||||||
await onStart(parameters);
|
await onStart(parameters);
|
||||||
final response = await call(parameters);
|
final response = await call(parameters);
|
||||||
if (response.isErr) {
|
if (response.isErr) {
|
||||||
@ -53,13 +52,11 @@ abstract class UseCase<Parameters, ReturnType>
|
|||||||
} else if (response.isOk && response.ok != null) {
|
} else if (response.isOk && response.ok != null) {
|
||||||
await _onSuccess(response.ok as ReturnType);
|
await _onSuccess(response.ok as ReturnType);
|
||||||
}
|
}
|
||||||
|
return response;
|
||||||
return response.ok!;
|
} catch (e) {
|
||||||
},
|
return Err(ClientException(e.toString()));
|
||||||
(error) => ClientException(
|
}
|
||||||
error.toString(),
|
}
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Abtstract classic usecase.
|
/// Abtstract classic usecase.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user