Better handling of JS exceptions in sync/validation functions

Arbitrary JS exceptions weren't being logged as warnings, just returned
as 500 statuses. This caused confusion for developers debugging their
apps. Exceptions are now logged. (Fixes #32)