Minor bug fix.
Added basic HTTP-level error handling.