Esempio n. 1
0
        public static ResultWebApi <T> Exception <T>(this T data, Exception exception)
        {
            EnumInfo errorCode = null;
            string   errorMsg  = "";

            if (exception.IsExtendType <Exception_Basic>())
            {
                var e = exception as Exception_Basic;

                errorCode = e.ECode;
                errorMsg  = e.Message;
            }
            else
            {
                errorCode = Enum_StateCode.SysError;
#if DEBUG
                errorMsg = exception.Message;
#else
                errorMsg = "程序出现错误,请联系管理员";
#endif
            }

            ResultWebApi <T> result = ToResultWebApi <T>(default(T), errorCode.ToIntString(), errorMsg);

            return(result);
        }
Esempio n. 2
0
        public static ResultWebApi <T> ToResultWebApi <T>(this T data, string code, string msg)
        {
            ResultWebApi <T> result;

            result        = new ResultWebApi <T>();
            result.Status = true;
            result.Code   = int.Parse(code);
            result.Msg    = msg;
            result.Data   = data;

            return(result);
        }