Posts an error message to the impCentral device log
Device + Agent
The error to be logged
This method logs an error message to the server-side, per-device log file. The message is automatically timestamped by the server, highlighted as an error, and displayed in impCentral’s device log.
server.error() assumes that you are passing valid UTF-8 code sequences. If it doesn’t recognise the string as UTF-8, it will convert it to binary.
Whereas server.log() is a generic message-logging method, server.error() is intended to help developers by highlighting error messages in the log. It prefixes the passed error message with
ERROR: with a blue background, to help such messages stand out in a way that is impossible to achieve with server.log(). It also simplifies the process of locating error messages in the log when using textual searches:
If the imp has been disconnected from the server and WiFi disabled, typically with a server.disconnect() call, any subsequent use of server.error() may cause the imp’s WiFi radio to be powered back on and a connection to be established with the Electric Imp impCloud™. This occurs when SUSPEND_ON_ERROR has been selected as the imp’s timeout policy. If the policy has been set to RETURN_ON_ERROR, however, WiFi will not be re-enabled until your code calls server.connect(). Log messages posted between the disconnection and subsequent re-connection will be lost; the method will return the value SEND_ERROR_NOT_CONNECTED.
The following examples show contexts for the use of server.error(). The second example highlights where you might use server.error() alongside server.log().