User Tools

Site Tools


errorhandler_class

This is an old revision of the document!


Errorhandler class

Platform utilises a custom error handler, and a custom shutdown function that ensures that all semaphores are released on script end.

There are also some utility functions for debugging code.

Typechecking

To introduce strict type checking on functions, the class introduces the checkParams() which takes a variable number of parameters, but always in pairs of two.

One pass a variable to the function and then a type name, and if the variable doesn't match the given type, then an error is triggered.

Example:

/**
 * Display name and age of person.
 * @param string $name Name of person.
 * @param int $age Age of person.
 */
function displayNameAndAge($name, $age) {
  Errorhandler::checkParams($name, 'string', $age, 'int');
  echo $name.' - '.$age.' years.';
}

This will trigger an error if the $name and $age variable isn't of the correct types.

Types

The following types can be checked. If anything else is typed it is considered a name of a class.

string
int
integer
float
array
resource
boolean
errorhandler_class.1582326725.txt.gz · Last modified: 2020/02/21 23:12 by sahl

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki