Some error handling

Read the commit messages.

Also created a related issue https://github.com/vkaravir/a-plus/issues/77 because the fix proved to be non-trivial.