Skip to content

Commit

Permalink
Merge pull request #24 from Ali-YousefiTelori/develop
Browse files Browse the repository at this point in the history
add OnExceptionHandler
  • Loading branch information
Ali-YousefiTelori authored Dec 29, 2023
2 parents a587ba2 + 149841d commit 3e8ac7a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ namespace EasyMicroservices.UI.Cores;
/// </summary>
public class ApiBaseViewModel : BaseViewModel
{

/// <summary>
///
/// </summary>
public Func<ErrorContract,Task<bool>> OnExceptionHandler { get; set; }
/// <summary>
///
/// </summary>
Expand All @@ -30,7 +33,7 @@ public async virtual Task ExecuteApi<TResult>(Func<Task<object>> getServerResult
if (response.IsSuccess)
await onSuccess(response);
else
await DisplayServerError(response.Error);
await InternalDisplayServerError(response.Error);
}
catch (Exception ex)
{
Expand Down Expand Up @@ -64,7 +67,7 @@ public virtual async Task ExecuteApi(Func<Task<object>> getServerResult, Func<Ta
if (response.IsSuccess)
await onSuccess?.Invoke();
else
await DisplayServerError(response.Error);
await InternalDisplayServerError(response.Error);
}
catch (Exception ex)
{
Expand All @@ -78,4 +81,10 @@ public virtual async Task ExecuteApi(Func<Task<object>> getServerResult, Func<Ta
UnBusy();
}
}

async Task InternalDisplayServerError(ErrorContract error)
{
if (OnExceptionHandler == null || !await OnExceptionHandler(error))
await DisplayServerError(error);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Platforms>AnyCPU;x64;x86</Platforms>
<Authors>EasyMicroservices</Authors>
<IsPackable>true</IsPackable>
<Version>0.0.0.13</Version>
<Version>0.0.0.14</Version>
<Description>Model View View Model</Description>
<Copyright>[email protected]</Copyright>
<PackageTags>mvvm,mvpvm,modelview,modelviewviewmodel</PackageTags>
Expand Down

0 comments on commit 3e8ac7a

Please sign in to comment.