public override void OnException(ExceptionContext context) { CoreError dgmError; if (context.Exception is CoreException exception) { var ex = exception; context.Exception = null; dgmError = ex.Error; } else if (context.Exception is UnauthorizedAccessException) { dgmError = new CoreError("Unauthorized access", StatusCodes.Status401Unauthorized); } else { var env = (IHostingEnvironment)context.HttpContext.RequestServices.GetService(typeof(IHostingEnvironment)); var msg = "An unhandled error occurred."; string stack = null; if (!env.IsProduction()) { msg = context.Exception.Message; stack = context.Exception.StackTrace; } dgmError = new CoreError($"{msg} {stack}"); } context.HttpContext.Response.StatusCode = dgmError.StatusCode; context.Result = new JsonResult(dgmError, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); base.OnException(context); }
public void OnError(CoreError error, string message) { labelStatus.Text = message; }
private void HandleError(Enum domain, string error_message, string debug) { Close(true); error_message = error_message ?? Catalog.GetString("Unknown Error"); if (domain is ResourceError) { ResourceError domain_code = (ResourceError)domain; if (CurrentTrack != null) { switch (domain_code) { case ResourceError.NotFound: CurrentTrack.SavePlaybackError(StreamPlaybackError.ResourceNotFound); break; default: break; } } Log.Error(String.Format("GStreamer resource error: {0}", domain_code), false); } else if (domain is StreamError) { StreamError domain_code = (StreamError)domain; if (CurrentTrack != null) { switch (domain_code) { case StreamError.CodecNotFound: CurrentTrack.SavePlaybackError(StreamPlaybackError.CodecNotFound); break; default: break; } } Log.Error(String.Format("GStreamer stream error: {0}", domain_code), false); } else if (domain is CoreError) { CoreError domain_code = (CoreError)domain; if (CurrentTrack != null) { switch (domain_code) { case CoreError.MissingPlugin: CurrentTrack.SavePlaybackError(StreamPlaybackError.CodecNotFound); break; default: break; } } if (domain_code != CoreError.MissingPlugin) { Log.Error(String.Format("GStreamer core error: {0}", (CoreError)domain), false); } } else if (domain is LibraryError) { Log.Error(String.Format("GStreamer library error: {0}", (LibraryError)domain), false); } OnEventChanged(new PlayerEventErrorArgs(error_message)); }
private void HandleError(GLib.GException ex) { TrackInfo failed_track = CurrentTrack; Close(true); var error_message = String.IsNullOrEmpty(ex.Message) ? Catalog.GetString("Unknown Error") : ex.Message; if (ex.Domain == Gst.Global.ResourceErrorQuark()) { ResourceError domain_code = (ResourceError)ex.Code; if (failed_track != null) { switch (domain_code) { case ResourceError.NotFound: failed_track.SavePlaybackError(StreamPlaybackError.ResourceNotFound); break; default: break; } } Log.Error(String.Format("GStreamer resource error: {0}", domain_code), false); } else if (ex.Domain == Gst.Global.StreamErrorQuark()) { StreamError domain_code = (StreamError)ex.Code; if (failed_track != null) { switch (domain_code) { case StreamError.CodecNotFound: failed_track.SavePlaybackError(StreamPlaybackError.CodecNotFound); break; default: break; } } Log.Error(String.Format("GStreamer stream error: {0}", domain_code), false); } else if (ex.Domain == Gst.Global.CoreErrorQuark()) { CoreError domain_code = (CoreError)ex.Code; if (failed_track != null) { switch (domain_code) { case CoreError.MissingPlugin: failed_track.SavePlaybackError(StreamPlaybackError.CodecNotFound); break; default: break; } } if (domain_code != CoreError.MissingPlugin) { Log.Error(String.Format("GStreamer core error: {0}", domain_code), false); } } else if (ex.Domain == Gst.Global.LibraryErrorQuark()) { Log.Error(String.Format("GStreamer library error: {0}", ex.Code), false); } OnEventChanged(new PlayerEventErrorArgs(error_message)); }
public static Error ToError(this CoreError error, params object[] args) { var name = ERROR_NAME_PREFIX + error.ToString().ToUpper(); return(Error.Factory.FromResource((uint)error, name, ResourceCoreErrors.ResourceManager, args)); }
public String this[CoreError error] => this[error.Type];