Group your errors together in logical units, and determine the convention you want to use. Some people use namespacing, or numbered grouping to make errors easily identifiable, but it largely depends on how many error codes you need to support, and how you want to group them. There isn't a 'standard' convention that I know of.
In my experience, that's really up to you. Error codes, however defined, will always have to be explained by you, so you can assign/group them however you please. Users don't care.
发布评论
评论(2)
将错误按逻辑单元分组,并确定要使用的约定。有些人使用命名空间或编号分组来使错误易于识别,但这很大程度上取决于您需要支持多少个错误代码,以及您希望如何对它们进行分组。据我所知,没有“标准”约定。
Group your errors together in logical units, and determine the convention you want to use. Some people use namespacing, or numbered grouping to make errors easily identifiable, but it largely depends on how many error codes you need to support, and how you want to group them. There isn't a 'standard' convention that I know of.
根据我的经验,这完全取决于你。错误代码无论如何定义,都必须由您进行解释,因此您可以根据需要对它们进行分配/分组。用户不在乎。
In my experience, that's really up to you. Error codes, however defined, will always have to be explained by you, so you can assign/group them however you please. Users don't care.