Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix server error messages #27

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading