Enhanced error handling

This is the server-side code for error handling Wave on both client and
server. This will help reduce the amount of errors and random closes you
get by attempting to resolve the situation silently and automatically,
or by displaying a useful error message.