Added check-error method to the database object.

Every other database method calls check-error to raise a user error if something goes wrong.
Changed error handling.

The error handling now uses "try" because the database object methods raise a user error.