HTML5: Fixed error handling in API