private void HandleS_Exception(S_Exception msg) { //Debug.Log("S_Exception"); Debug.Log(msg.code + "," + msg.description + " ==>" + msg.trace); string detail = "Error: " + msg.code + "\n" + msg.description + "\n" + msg.trace; popExceptionPanel(detail); }
/// <summary> /// Converts a exception to a proto exception /// </summary> /// <param name="ex">The ex.</param> /// <param name="code">The code<see cref="string"/></param> /// <returns>the proto Exception</returns> public static S_Exception ToProtoException(this Exception ex, string code = null) { S_Exception result = new S_Exception(); result.Message = ex.Message; result.StackTrace = ex.StackTrace; result.Code = code ?? ""; if (ex.InnerException != null) { result.InnerException = ex.InnerException.ToProtoException(); } return(result); }
/// <summary> /// To the exception. /// </summary> /// <param name="ex">The ex.</param> /// <returns></returns> private static Exception ToBaseException(this S_Exception ex) { Exception result = null; if (ex.InnerException != null) { result = new Exception(ex.Message, ex.InnerException.ToBaseException()); } else { result = new Exception(ex.Message); } if (!string.IsNullOrEmpty(ex.Code)) { return(new Exception(ex.Code, result)); } return(result); }
/// <summary> /// Converts a exception to a proto exception /// </summary> /// <param name="p_Exception">The p_Exception<see cref="S_Exception"/></param> /// <param name="throwException">The throwException<see cref="bool"/></param> /// <returns>the proto Exception</returns> public static Exception ToException(this Any proto, bool throwException = false) { Exception ex = null; S_Exception p_Exception = proto.CastToModel <S_Exception>(); if (p_Exception == null) { throw new Exception("Excpected S_Exception proto, but received: " + p_Exception.GetType().FullName); } if (p_Exception != null) { ex = p_Exception.ToBaseException(); } if (!string.IsNullOrEmpty(p_Exception.Message) && ex != null) { if (throwException) { throw new Exception(p_Exception.Message, ex); } return(new Exception(p_Exception.Message, ex)); } else if (!string.IsNullOrEmpty(p_Exception.Message)) { if (throwException) { throw new Exception(p_Exception.Message); } return(new Exception(p_Exception.Message)); } if (throwException) { throw ex; } return(ex); }