When is it appropriate to use error codes?

后端 未结 10 1763
日久生厌
日久生厌 2020-12-10 01:36

In languages that support exception objects (Java, C#), when is it appropriate to use error codes? Is the use of error codes ever appropriate in typical enterprise applicati

10条回答
  •  渐次进展
    2020-12-10 02:18

    I've written many web services that are consumed by other (remote) applications. When things go badly with a request, customers more or less insist on getting a code, so that they don't have to do some horrific string comparison to find out what went wrong.

    Take HTTP result codes as a fine example of this sort of behavior. "200" means happy, "300" could go either way, "400" or "500" means start freaking out.

提交回复
热议问题