Exception handling 捕捉webmethod参数错误

Exception handling 捕捉webmethod参数错误,exception-handling,webmethod,Exception Handling,Webmethod,我有一个这样的方法 [WebMethod] public static string UpdateProduct(Products obj) { DbTools.runcmd(TSQLCreate.Update(obj)); return "SUCCESS"; } public class Products : Books { public Products() {

我有一个这样的方法


    [WebMethod]
    public static string UpdateProduct(Products obj)
    {
        DbTools.runcmd(TSQLCreate.Update(obj));
        return "SUCCESS";
    }
    

    public class Products : Books
    {
        public Products()
        {
            this.AddedDate = DateTime.Now;
            ///throw new NotImplementedException();
        }

        #region COMMON
        [SQLIDColumn]
        public int ProductID { get; set; }
        [SQLColumn]
        public string ProductName { get; set; }
        [SQLColumn]
        public string ProductCode { get; set; }
        [SQLColumn]
        public string Barcode { get; set; }
        ..............
        private bool isOnePrice;
        [SQLColumn]
        public bool IsOnePrice
        {
            get { return isOnePrice; }
            set { isOnePrice = value; }
        }

        private decimal onePrice;
        [SQLColumn]
        public decimal OnePrice
        {
            get
            {
                if (onePrice == 0M) onePrice = labelPrice;
                return onePrice;
            }
            set {onePrice = value;}
        }
    }
    
并有一个用JS创建的XHR请求,用于将obj传递给wetmethod


    SendOBJToMethod("some.aspx/UpdateProduct"
    ,obj // My Product Object
    ,function() { alert("Updated"); }); //SUCCESS FUNC
    
产品类别就是这样


    [WebMethod]
    public static string UpdateProduct(Products obj)
    {
        DbTools.runcmd(TSQLCreate.Update(obj));
        return "SUCCESS";
    }
    

    public class Products : Books
    {
        public Products()
        {
            this.AddedDate = DateTime.Now;
            ///throw new NotImplementedException();
        }

        #region COMMON
        [SQLIDColumn]
        public int ProductID { get; set; }
        [SQLColumn]
        public string ProductName { get; set; }
        [SQLColumn]
        public string ProductCode { get; set; }
        [SQLColumn]
        public string Barcode { get; set; }
        ..............
        private bool isOnePrice;
        [SQLColumn]
        public bool IsOnePrice
        {
            get { return isOnePrice; }
            set { isOnePrice = value; }
        }

        private decimal onePrice;
        [SQLColumn]
        public decimal OnePrice
        {
            get
            {
                if (onePrice == 0M) onePrice = labelPrice;
                return onePrice;
            }
            set {onePrice = value;}
        }
    }
    
问题: 当我以PropertyCIMAL OnePrice为空发送objectproduct时,我得到的错误值不是十进制的有效值

让我知道,是谁抛出的异常? 因为我想更改此消息

谢谢