public virtual JsonObject ToJsonObject() { JsonObject answer = new JsonObject(); answer.put("localRealm", _localRealm); return answer; }
public static JsonObject ToJsonObject(BaseException baseException) { JsonObject answer = new JsonObject(); answer.put("errorDomain", baseException.ErrorDomain); // null is ok answer.put("faultCode", baseException.FaultCode); answer.put("faultMessage", baseException.Message); answer.put("underlyingFaultMessage", baseException.UnderlyingFaultMessage); answer.put("originator", baseException.getOriginator()); JsonArray jsonStackTrace; { jsonStackTrace = new JsonArray(); String[] stackTrace = ExceptionHelper.getStackTrace(baseException, true); for (int i = 0, count = stackTrace.Length; i < count; i++) { jsonStackTrace.Add(stackTrace[i]); } stackTrace = ExceptionHelper.getStackTrace(baseException, false); for (int i = 0, count = stackTrace.Length; i < count; i++) { jsonStackTrace.Add(stackTrace[i]); } } answer.put("stackTrace", jsonStackTrace); JsonObject faultContext = new JsonObject(); answer.put("faultContext", faultContext); return answer; }
public JsonObject toJsonObject() { JsonObject answer = new JsonObject(); answer.put("identifier", _identifier); JsonArray subjects = new JsonArray(); foreach (KeyValuePair<String, Subject> kvp in _clients) { Subject client = kvp.Value; JsonObject subjectData = new JsonObject(); subjectData.put("identifier", client.Username); subjectData.put("password", client.Password); subjectData.put("label", client.Label); subjects.Add(subjectData); } answer.put("subjects", subjects); return answer; }
public static JsonObject ToJsonObject(Exception exception) { if (exception is BaseException) { return ToJsonObject((BaseException)exception); } JsonObject answer = new JsonObject(); answer.put("errorDomain", null); // null is ok answer.put("faultCode", BaseException.DEFAULT_FAULT_CODE); // answer.put("faultMessage", exception.Message); answer.put("underlyingFaultMessage", ExceptionHelper.getUnderlyingFaultMessage(exception)); String[] stackTrace = ExceptionHelper.getStackTrace(exception, true); JsonArray jsonStackTrace = new JsonArray(stackTrace.Length); for (int i = 0, count = stackTrace.Length; i < count; i++) { jsonStackTrace.Add(stackTrace[i]); } answer.put("stackTrace", jsonStackTrace); String originator; { StackTrace st = new StackTrace(exception, true); StackFrame frame0 = st.GetFrame(0); MethodBase method = frame0.GetMethod(); String className = method.DeclaringType.Name; String methodName = method.Name; int lineNumber = frame0.GetFileLineNumber(); if (0 != lineNumber) { originator = String.Format("{0}:{1:x}", className, lineNumber); } else if (null != methodName) { originator = String.Format("{0}:{1}", className, methodName); } else { originator = String.Format("{0}:?", className); } } answer.put("originator", originator); JsonObject faultContext = new JsonObject(); answer.put("faultContext", faultContext); return answer; }