Error messages

From ScarletDME
Jump to navigation Jump to search

Programs covered by this note:

  • k_error
  • sysmsg

When something goes wrong the C code generally calls k_error (in src/k_error.c) with a text message pulled from the Pick file MESSAGES by sysmsg() (src/messages.c).

Each entry in MESSAGES is keyed by the QM internal error code. These messages contain C style printf codes (eg %d for an integer %s for a char string) which can be passed into k_error as additional params and will be inserted into these messages. This method allows a generic message to be displayed with circumstantial information inserted.

Ironically it does mean the Messages in the data file are fairly well tied to the hard coded number and type of params that are passed to k_error.

When changing messages beware not to alter the %'s such that places you aren't working on can still call k_error meaningfully.