handle error properly when the file is not stored in the local CouchDB