Best way to define error codes/strings in Java?

前端 未结 13 776
别那么骄傲
别那么骄傲 2020-12-12 08:37

I am writing a web service in Java, and I am trying to figure out the best way to define error codes and their associated error strings. I need to have a nu

13条回答
  •  不思量自难忘°
    2020-12-12 09:11

    Using interface as message constant is generally a bad idea. It will leak into client program permanently as part of exported API. Who knows, that later client programmers might parse that error messages(public) as part of their program.

    You will be locked forever to support this, as changes in string format will/may break client program.

提交回复
热议问题