Formalized error handling/throwing

More consistent error messages, and promises are now rejected with
Error objects proper.