public bool resultHandleHttpErrors(CharpCtx ctx) { if (ctx.status.Cancelled) { handleError(ERRORS [(int)ERR.HTTP_CANCEL], ctx); return(false); } if (ctx.status.Error != null) { CharpError err = ERRORS [(int)ERR.HTTP_SRVERR]; err.msg = String.Format(Catalog.GetString("HTTP WebClient error: {0}"), ctx.status.Error.ToString()); handleError(err, ctx); return(false); } byte[] result = ctx.Result; if (result == null || result.Length == 0) { handleError(ERRORS[(int)ERR.HTTP_CONNECT], ctx); return(false); } return(true); }
public void handleError(JToken err, CharpCtx ctx = null) { CharpError cerr = new CharpError { code = (int)err["code"], sev = (ERR_SEV)((int)err["sev"]), desc = (string)err["desc"], msg = (string)err["msg"], lvl = (ERR_LEVEL)((int)err["level"]), key = (string)err["key"], state = err["state"] != null? (string)err["state"]: "", statestr = (string)err["statestr"] }; handleError(cerr, ctx); }
public override void handleError(CharpError err, CharpCtx ctx = null) { if (ctx != null && ctx.error != null && !ctx.error (err, ctx)) { return; } Gtk.Application.Invoke (delegate { CharpGtkErrorDlg dlg = new CharpGtkErrorDlg (err, ctx); if (ctx is CharpGtkCtx && ((CharpGtkCtx) ctx).parent != null) { dlg.TransientFor = ((CharpGtkCtx) ctx).parent; } else if (parent != null) { dlg.TransientFor = parent; } dlg.Run (); }); }
public override void handleError(CharpError err, CharpCtx ctx = null) { if (ctx != null && ctx.error != null && !ctx.error(err, ctx)) { return; } Gtk.Application.Invoke(delegate { CharpGtkErrorDlg dlg = new CharpGtkErrorDlg(err, ctx); if (ctx is CharpGtkCtx && ((CharpGtkCtx)ctx).parent != null) { dlg.TransientFor = ((CharpGtkCtx)ctx).parent; } else if (parent != null) { dlg.TransientFor = parent; } dlg.Run(); }); }
private JObject handleResult(CharpCtx ctx, bool isReply) { if (!resultHandleHttpErrors(ctx)) { return(null); } if ((isReply || ctx.asAnon) && ctx.reply_complete_handler != null) { if (ctx.useCache) { cacheSet(ctx, ctx.status); } if (ctx.reply_complete_handler(ctx)) { return(null); } } byte[] result = ctx.Result; JObject data; try { data = JSON.decode(result); } catch (Exception e) { CharpError err = ERRORS [(int)ERR.AJAX_JSON]; err.msg = String.Format(Catalog.GetString("Error: {0}, Data: {1}"), e.Message, Encoding.UTF8.GetString(result)); handleError(err, ctx); return(null); } if (data["error"] != null) { handleError(data ["error"], ctx); return(null); } return(data); }
public void handleError(Dictionary<string, object> err, CharpCtx ctx = null) { CharpError cerr = new CharpError { code = Int32.Parse ((string) err["code"]), sev = (ERR_SEV) Int32.Parse ((string) err["sev"]), desc = (string) err["desc"], msg = (string) err["msg"], lvl = (ERR_LEVEL) Int32.Parse ((string) err["level"]), key = (string) err["key"], state = (string) err["state"], statestr = (string) err["statestr"] }; handleError (cerr, ctx); }
public abstract void handleError(CharpError err, CharpCtx ctx = null);