Errors and log
What the component gives your code to catch, record and report 4D errors, and to trace what happens where the debugger cannot reach: web requests, workers, scheduled tasks.
The log: BSPK_LOG
BSPK_LOG("Order.validate"; "refused"; $vo_POST; $Order)
- Up to 9 values of any type, written on one line:
[timestamp] v1 : v2 : …. Objects and collections are written as JSON, entities and entity selections are converted first. - File:
Logs/bspk.login the data folder, created if missing. Usable from your project as well as from a worker. - No levels, no rotation, and the file is deleted at every startup. It is a diagnostic tool, not a permanent log: copy the file before restarting if you need it.
- It is the only trace available inside a web request: see Troubleshooting.
The three error handlers
To install with ON ERR CALL in a process:
| Handler | Records in BSPK_ERROR | Sends the error mail | Dialog | For |
|---|---|---|---|---|
BSPK_ERROR_HANDLER | yes | yes | yes (except for assertions); the user can cancel the operation | processes with an interface |
BSPK_ERROR_SILENT | yes | yes | no | server processes, workers, batch jobs |
BSPK_ERROR_MUTED | no | no | no | known errors that must neither interrupt nor alert |
ON ERR CALL("BSPK_ERROR_SILENT")
// … server-side work …
ON ERR CALL("")
BSPK_ERROR_HANDLER and BSPK_ERROR_SILENT:
- collect the error stack, the method, line and formula, the web context when there is one (URL, headers, session) and the call chain. They rely on your project's
BSPH_GET_ERROR_VARIABLESmethod for that: do not delete it; - deduplicate: the same error (same code, method, line, formula and machine) within the following minute creates no new record, it increments the previous one's
counter, and the mail is not sent again if it already went out.
BSPK_ERROR_MUTED only sets the process variable vb_Erro_Silent to true: test it after the statement that could fail.
In DEV mode
The component's processes install BSPK_ERROR_HANDLER, except in DEV mode, where they leave it to the 4D debugger, unless vo_Param.vb_erroHandler is true (see Parameter files). Consequence: an error seen in production may never have been recorded on the development machine. The error dialog's Trace button only appears in DEV mode, interpreted.
The
BSPK_ERROR_TESTtest method of previous versions no longer exists in version 21. To test a handler, raise an error yourself, for instanceON ERR CALL("BSPK_ERROR_SILENT")thenASSERT(False).
Where error mails go
The handlers send their mails through BSPK_ERRO_SEND_MAIL, with the vo_Mail server:
| Field | Value |
|---|---|
| Sender | vo_Mail.vt_User |
| Recipient | vo_RedirectMapping[<machine name>], otherwise vt_RedirectMail if not empty, otherwise vo_Mail.vt_Forwarder. The redirection applies in every mode, production included. |
| Subject | [<application>]Erreur sur <application> |
Errors raised by this sending are themselves muted: a wrong SMTP setting fails quietly. Test an error mail once a server is configured.
See also
- Parameter files:
vo_Mail, redirections - The Mail class
- Troubleshooting

