How to catch a specific HttpException (#0x80072746) in an IHttpHandler

北慕城南 提交于 2019-12-06 00:32:26

Int32 is not really too small to hold 0x80072746; only in “normal” notation, this number is negative: 0x80072746 == -2147014842, you can create a constant to compare the error code against:

const int ErrConnReset = unchecked((int)0x80072746);

or

const int ErrConnReset = -2147014842;

The HttpException.ErrorCode property gives you the error code you are looking for. Make it look similar to this:

        try {
            //...
        }
        catch (HttpException ex) {
            if ((uint)ex.ErrorCode != 0x80072746) throw;
        }

In computer science, a negative integer is represented in hexadecimal with a the first bit set to 1 (source: wikipediat).

According that, the hexadecimal number 0x80072746 can be written in base 2 :

1000 0000 0000 0111 0010 0111 0100 0110

The first bit is set... then it correspond actually to this number :

-0111 1111 1111 1000 1101 1000 1011 1010

which can finally be represented in base 10 like this :

-2147014842

which is finally, actually an correct integer.

Don't know if it can help you to solve the problem.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!