public static class ApiHelper { public static ReslultInfo<K> Try<K>(Action<ReslultInfo<K>> action) { var r = new ReslultInfo<K>(); try { action(r); } catch (Exception ex) { r.code = ReslultCode.error; r.desc = ex.Message; } return r; } } public enum ReslultCode { sucess, error } public class ReslultInfo<T> { public ReslultInfo() { code = ReslultCode.sucess; desc = ""; } //result:sucess/error public ReslultCode code { get; set; } public string desc { get; set; } public T Data { get; set; } }
时间: 2024-10-17 09:25:10