Error handling

Added some error handling and a test using canvas