Register an callback to receive error messages.
onError(
handler: (message: string) => void
): void;
Display errors to the user with the front-end library of your choice.
function displayError(message) {
// Show a growl or banner notification
}
j.onError(displayError);
Log errors on the server using very similar looking code.