将异常类型添加到位框架已知异常

时间:2017-09-13 16:12:02

标签: bit-framework

基于docs,在bit-framework中有一些已知的异常类型。

https://docs.bit-framework.com/docs/bit-server-side/web-api.html#exceptions

我们如何扩展此列表?

1 个答案:

答案 0 :(得分:2)

看一下以下代码:

public class MyException : Exception, IKnownException /*Required*/, IHttpStatusCodeAwareException /*Optional >> Default is InternalServerError (500)*/
{
    public MyException(string message)
        : base(message)
    {
    }

    public HttpStatusCode StatusCode { get; set; } = HttpStatusCode.Conflict;
}

希望这有帮助