private void SetNotifierContent(UiNotifierBase notifier, ErrorDescriber describer) { var content = new[] { new { Story = Resource.String.api_errors_400, ExType = typeof(HttpResponse400Exception) }, new { Story = Resource.String.api_errors_500, ExType = typeof(HttpResponse500Exception) }, new { Story = Resource.String.api_errors_timeout_story, ExType = typeof(TaskCanceledException) }, new { Story = Resource.String.api_errors_parse_story, ExType = typeof(JsonReaderException) }, new { Story = Resource.String.api_errors_connection_story, ExType = typeof(NotConnectedToInternetException) }, new { Story = Resource.String.api_errors_no_data_story, ExType = typeof(HttpResponse204Exception) } } .FirstOrDefault(item => item.ExType == describer.ExceptionType); if (content == null && !describer.ErrorCode.IsBlank()) { notifier.Story = string.Format(this._context.GetString(Resource.String.api_errors_200), describer.ErrorCode); } else if (content != null) { notifier.Story = string.Format( this._context.GetString(content.Story), describer.HttpStatusCode > 299 ? describer.HttpStatusCode.ToString() : string.Empty); } else { notifier.Story = this._context.GetString(Resource.String.api_errors_unknown_error_occured); } }
public void ErrorOccured(ErrorDescriber describer) { UiNotifierBase notifier = Activator.CreateInstance(describer.UiNotifierType) as UiNotifierBase ?? new Flash(); this.SetNotifierContent(notifier, describer); string story = notifier.Story.ToString(); this.Notify(describer, story); }