Error Handling and Logging¶
In can happen that your CakePHP controller method throws an exception. Exceptions are only for debugging and handling of unexpected cases. It will always trigger the exception handling on the client side, read more about it here.
During development it can also be helpful to write any CakePHP error to your browser console, here's the description to do this in Chrome.
To enable this simply include /bancha/js/tracekit/tracekit.js in your app. In debug mode there will be no changes. In production mode (CakePHP debug level 1 and 0) all client-side errors will automatically be logged to the CakePHP log file js_error.log, including the full stack trace.
You will often want to log some information to the console in debug mode. But if you use the console.info directly the code will break on devices without a console. For this you can use Bancha.Logger.info(msg), which abstracts the console.
To use this feature simply require Bancha.Logger in your application.
If you want to log warning and errors, use Bancha.Logger.warn(msg) and Bancha.Logger.error(msg). In debug mode these will be logged to the console (or as alert if there is no console), in production mode these errors will be logged to the CakePHP log file js_error.log.
If you want the force Bancha to always log the message to the server, set the second argument to true: Bancha.Logger.error(msg, true);