// Demo of handling special composite exceptions that need to be converted to one or more errors in the response. // Ex: VITA ORM defines ClientFaultException that contains multiple validation errors; the call to SaveChanges // might throw this exception, with multiple validation errors inside. We will catch the ClientFaultException // in the OperationError event handler, unpack errors inside and add them as separate errors in the response. // Here we catch AggregateException to demo/test the technique; we have a resolver that throws this exc with // multiple child exceptions inside. private static void Events_OperationError(object sender, OperationErrorEventArgs args) { if (args.Exception is AggregateException aex) { var ctx = args.RequestContext; foreach (var childExc in aex.InnerExceptions) { ctx.AddError(childExc.Message, args.RequestItem, errorType: "Aggr-Error"); } // clear original exc args.ClearException(); } }
public void AddError(FieldContext fieldContext, Exception ex, string errorType) { _failed = true; // fire event var eventArgs = new OperationErrorEventArgs(_requestContext, this._mappedOpField.Field, ex); _requestContext.Server.Events.OnOperationError(eventArgs); if (eventArgs.Exception == null) { return; // event handler cleared error } // add error fieldContext.AddError(ex, errorType); }
void operation_Error(object sender, OperationErrorEventArgs e) { Invoke(() => errorOutput.DisplayError(e.ErrorMessage, e.Exception)); }
void operation_Error(object sender, OperationErrorEventArgs e) { errorOutput.DisplayError(e.ErrorMessage); }
void FavouritesManager_OperationError(object sender, OperationErrorEventArgs e) { Twitter_OperationError(sender, e); }
void Twitter_OperationError(object sender, OperationErrorEventArgs e) { SetLoading(false); //MessageBox.Show(e.Message); }
private void operation_Error(object sender, OperationErrorEventArgs e) { Error = e.Error; }