ServiceStack:当我在服务中抛出[MyCustom]异常时,我得到“[MyCustom] Exception未被用户代码处理”

时间:2014-03-07 17:49:45

标签: c# exception servicestack-bsd

Service课程中我有Post方法:

    public void Post(UpdateAdd request)
    {
        try
        {
            Service.Db.Insert(some_data);
        }
        catch (SqlException e)
        {
            switch (e.Number)
            {
                case SqlErrorNumbers.UniqueIndex: 
                    throw new UniqueIndexException();
            }
        }
    }

当我点击F5(调试 - >运行)时,服务代码在catch结束时停止并说:" UniqueIndexException未被用户代码"处理在我的客户端代码中,我必须捕获一般的WebException而不是像文档says here一样的WebServiceException。

我失踪了什么?

如何使新的UniqueIndexException();在调试模式下运行时不要停止我的代码执行,以及如何知道在服务中抛出了UniqueIndexException()。 WebException的InnerException为null。

0 个答案:

没有答案