Ejemplo n.º 1
0
        public static JsonResult <T> Execute <T>(JsonResultHandler <T> CodeFunc) where T : new()
        {
            var result = new JsonResult <T>();

            try
            {
                CodeFunc(result);
            }
            catch (Exception ex)
            {
                //todo: some flag needed to show friendly errors
                result.AddError(ex);
                Logging.Logger.Error("API Error", ex);
                if (ex.InnerException != null)
                {
                    result.AddError(ex.InnerException);
                }
            }
            return(result);
        }