Exception handling
From MapbenderWiki
User:Christoph Baudson (Module maintainer)
Contents |
Description
english
setting in configuration file mapbender.conf
# --------------------------------------------
# Mapbender error logging
# --------------------------------------------
define("LOG_LEVEL_LIST", "off,error,warning,notice,all");
define("LOG_LEVEL", "all");
define("LOG_JS", "on"); // "on", "alert", "console", "off"
- LOG_LEVEL_LIST: list of available log levels.
- LOG_LEVEL: a single entry of LOG_LEVEL_LIST:
- off: no logging.
- error: only errors will be logged.
- warning: only errors and warnings will be logged.
- notice: errors and warnings and notices will be logged.
- all: everything will be logged (at the moment equal to the setting "notice").
- LOG_JS: Sets the handling of JS exceptions: The log entries will be
- on: written in a log file (just like in PHP).
- alert: alerted in the browser. Useful for debugging with Internet Explorer.
- console: displayed in the Firebug console. Useful when debugging with Firefox.
- off: pulverised.
usage in PHP
Throw an exception (as before) via
$error = new mb_exception($message);
A warning may be thrown like this
$error = new mb_warning($message);
and a notice like this
$error = new mb_notice($message);
Both classes are inherited from mb_log, which basically is the "old" (pre 2.4.1) class mb_exception. For possible new types, a new class may be added easily, note that all the files listed below have to be changed.
usage in JavaScript
Throw it via
var e = new Mb_exception(message); var e = new Mb_warning(message);
Please note the different spelling: the JS object is spelled with a capital "M". The php name will be corrected in a future refactoring process. As each JS exception triggers an AJAX request, it might be sensible to consider turning them off (or use console/alert) when server load is crucial.
deutsch
Einstellungen in der Konfigurationsdatei mapbender.conf
# --------------------------------------------
# Mapbender error logging
# --------------------------------------------
define("LOG_LEVEL_LIST", "off,error,warning,notice,all");
define("LOG_LEVEL", "all");
define("LOG_JS", "on"); // "on", "alert", "console", "off"
- LOG_LEVEL_LIST: Liste der verfügbaren Loggingstufen.
- LOG_LEVEL: Ein Eintrag der Liste LOG_LEVEL_LIST:
- off: es werden nichts geloggt.
- error: Es werden lediglich Fehlermeldungen geloggt.
- warning: Es werden Fehlermeldungen und Warnungen geloggt.
- notice: Es werden Fehlermeldungen und Warnungen und Hinweise geloggt.
- all: Es wird alles geloggt (Momentan entspricht das "notice").
- LOG_JS: Einstellung bzgl. Umgang mit JavaScript-Logging: Die Logeinträge werden
- on: wie in php in eine Logdatei geschrieben.
- alert: als ein alert im Browser ausgegeben. Sinnvoll beim Debuggen mit Internet Explorer.
- console: als ein Konsoleneintrag im Firebug ausgegeben. Sinnvoll beim Debuggen mit Firefox.
- off: ins Nirwana befördert.
usage in PHP
Eine Exception wird wie zuvor durch
$error = new mb_exception($message);
geworfen. Eine Warnung wird wie folgt ausgegeben:
$error = new mb_warning($message);
Für einen Hinweis folgendes eingeben:
$error = new mb_notice($message);
Alle Klassen erben von mb_log, die im Prinzip der "alten" (vor 2.4.1) Klasse mb_exception entspricht. Für weitere Arten von Exceptions müssen neue Klassen angelegt werden. Änderungen müssen dabei in allen unten angegeben Dateien erfolgen.
usage in JavaScript
Wird wie folgt geworfen
var e = new Mb_exception(message); var e = new Mb_warning(message); var e = new Mb_notice(message);
Bitte die unterschiedliche Schreibweise beachten: das JS Objekt wird mit einem großen "M" geschrieben. Der Name der PHP-Klasse wird in einem zukünftigem Refactoring-Schritt erfolgen. Da jede JS Exception einen AJAX request auslöst, könnte es sinnvoll sein, das error logging für JS abzuschalten (or console/alert zu benutzen) wenn die Serverlast schon zu hoch ist.
Files
For this module the following files are required / Für dieses Modul werden die folgenden Dateien benötigt:

