Mini-Pattern: Error Codes

by Charles Miller on September 24, 2002

Name: Error Codes

Context:

You need to provide a stable platform for clients to interpret errors occurring in a networked application (for example a web service)

Forces:

  • You want to make it as easy as possible for a client writer to inform the user of abnormal conditions. The easier it is to write a client, the more likely your service will be quickly adopted.
  • You want to make it possible to write an advanced client that intercepts errors and handles them internally. For example, the client may wish to present messages in another language, or perform some action other than reporting the error to the user.
  • Clients should not break if a service's human-readable error codes are changed.

Therefore:

Present error messages both as an easily machine-parsed code, and as a textual description. Client writers may choose to pass the description straight to the user, to interpret the code and take some other action, or some combination of both.

Examples of use:

SMTP, NNTP, FTP, HTTP, etc...

Notably absent from:

Pretty much every web-service designed by amateurs.

Previously: Mon, 23 Sep 2002 14:44:55 GMT

Next: Tue, 24 Sep 2002 01:35:07 GMT