Test error design

From Emergent

Jump to: navigation, search

Error checking etc

See also check config design for the configuration checking system.

  • on taBase objects, use TestError and TestWarning, which automatically add object type, path, and, with arg, function name information to the error message, making it much easier to track down, and the message you enter can just be about the specific error condition -- can also be used in an if statement because it returns value of test:
  if(TestError((cell < 0) || (cell >= cell_size()), "IndexOfEl_Flat",
	       "cell index out of range")) return -1;
  • otherwise, use taMisc::Error or taMisc::Warning -- be sure to add as much relevant path/object/function information as possible so it can tracked down:
    taMisc::Warning("taiTokenPtrType::GetValue_impl: Value not set for type:",npt->name,
		    "because it is not keeping tokens");

Difference between Error and Warning

  • if the problem is such that the function cannot be carried out, e.g., due to bad args or something, and this is something that the user might call in a script/program, then use an Error -- an error will stop the program and give information about the function call from the script, etc. If the command shell is active, the user can then debug it. Otherwise, if it is not something that needs corrective action, then a Warning is fine.

Don't Use Exceptions!

  • we are not using exceptions for anything so far..
Personal tools