Skip to content

Commit

Permalink
Merge pull request #27 from Ali-YousefiTelori/develop
Browse files Browse the repository at this point in the history
Fix server error messages
  • Loading branch information
Ali-YousefiTelori authored Dec 29, 2023
2 parents ee5eaa3 + 9d0ddd7 commit 2f98193
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class ApiBaseViewModel : BaseViewModel
/// <param name="onSuccess"></param>
/// <param name="onError"></param>
/// <returns></returns>
public async virtual Task ExecuteApi<TResult>(Func<Task<object>> getServerResult, Func<MessageContract<TResult>, Task> onSuccess, Func<Exception, Task> onError = default)
public async virtual Task ExecuteApi<TResult>(Func<Task<TResult>> getServerResult, Func<MessageContract<TResult>, Task> onSuccess, Func<ErrorContract, Task> onError = default)
{
try
{
Expand Down Expand Up @@ -55,7 +55,7 @@ public async virtual Task ExecuteApi<TResult>(Func<Task<object>> getServerResult
/// <param name="onSuccess"></param>
/// <param name="onError"></param>
/// <returns></returns>
public virtual async Task ExecuteApi(Func<Task<object>> getServerResult, Func<Task> onSuccess = default, Func<Exception, Task> onError = default)
public virtual async Task ExecuteApi(Func<Task<object>> getServerResult, Func<Task> onSuccess = default, Func<ErrorContract, Task> onError = default)
{
try
{
Expand Down Expand Up @@ -85,6 +85,6 @@ public virtual async Task ExecuteApi(Func<Task<object>> getServerResult, Func<Ta
async Task InternalDisplayServerError(ErrorContract error)
{
if (OnGlobalServiceErrorHandler == null || !await OnGlobalServiceErrorHandler(error))
await DisplayServerError(error);
await OnServerError(error);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public virtual Task OnError(Exception exception)
/// </summary>
/// <param name="errorContract"></param>
/// <returns></returns>
public virtual Task DisplayServerError(ErrorContract errorContract)
public virtual Task OnServerError(ErrorContract errorContract)
{
return Task.CompletedTask;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public virtual void Execute(object parameter)
}
catch (InvalidResultOfMessageContractException ex)
{
_busyViewModel?.DisplayServerError(ex.MessageContract.Error);
_busyViewModel?.OnServerError(ex.MessageContract.Error);
}
catch (Exception ex)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ async Task InternalExecute(object parameter)
}
catch (InvalidResultOfMessageContractException ex)
{
_busyViewModel?.DisplayServerError(ex.MessageContract.Error);
_busyViewModel?.OnServerError(ex.MessageContract.Error);
}
catch (Exception ex)
{
Expand Down
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.16</Version>
<Version>0.0.0.17</Version>
<Description>Model View View Model</Description>
<Copyright>[email protected]</Copyright>
<PackageTags>mvvm,mvpvm,modelview,modelviewviewmodel</PackageTags>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public interface IBusyViewModel : INotifyPropertyChanged
/// </summary>
/// <param name="errorContract"></param>
/// <returns></returns>
Task DisplayServerError(ErrorContract errorContract);
Task OnServerError(ErrorContract errorContract);

/// <summary>
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public override Task OnError(Exception exception)
/// </summary>
/// <param name="errorContract"></param>
/// <returns></returns>
public override Task DisplayServerError(ErrorContract errorContract)
public override Task OnServerError(ErrorContract errorContract)
{
return Page.DisplayAlert("Server Error", $"{errorContract?.FailedReasonType}{Environment.NewLine}{errorContract?.Message}{Environment.NewLine}{errorContract?.Details}{Environment.NewLine}{errorContract?.StackTrace}", "Ok");
}
Expand Down

0 comments on commit 2f98193

Please sign in to comment.