public void ResumeException(string exceptionType, string detailMessage, JavaStackTrace[] stackTraces, JavaException[] suppressedExceptions, JavaException innerException) { if (isFreeze) { throw new InvalidOperationException("the exception has been frozen"); } ExceptionType = exceptionType; DetailMessage = detailMessage; StackTraces = stackTraces; SuppressedExceptions = suppressedExceptions; if (innerException != null) { InnerExceptionField.SetValue(this, innerException); } isFreeze = true; }
private static void AppendMessage(StringBuilder msg, string prefix, int indent, JavaException ex) { while (true) { for (var j = 0; j < indent; j++) { msg.Append("\t"); } if (!string.IsNullOrWhiteSpace(prefix)) { msg.Append(prefix); } msg.Append(ex.ExceptionType).Append(":").Append(ex.DetailMessage).Append(Environment.NewLine); if (ex.StackTraces != null && ex.StackTraces.Length > 0) { foreach (var trace in ex.StackTraces) { for (var j = 0; j < indent; j++) { msg.Append("\t"); } msg.Append(" at ").Append(trace).Append(Environment.NewLine); } } if (ex.SuppressedExceptions != null && ex.SuppressedExceptions.Length > 0) { foreach (var current in ex.SuppressedExceptions) { AppendMessage(msg, "Suppressed: ", indent + 1, current); } } if (ex.InnerException == null) { return; } prefix = "Caused by: "; ex = (JavaException)ex.InnerException; } }