def _ToBlobstoreError(error):
 error_map = {blobstore_service_pb.BlobstoreServiceError.INTERNAL_ERROR: InternalError, blobstore_service_pb.BlobstoreServiceError.BLOB_NOT_FOUND: BlobNotFoundError, blobstore_service_pb.BlobstoreServiceError.DATA_INDEX_OUT_OF_RANGE: DataIndexOutOfRangeError, blobstore_service_pb.BlobstoreServiceError.BLOB_FETCH_SIZE_TOO_LARGE: BlobFetchSizeTooLargeError, blobstore_service_pb.BlobstoreServiceError.PERMISSION_DENIED: PermissionDeniedError}
 desired_exc = error_map.get(error.application_error)
 return (desired_exc(error.error_detail) if desired_exc else error)

def _ToBlobstoreError ( error ) : error_map = { blobstore_service_pb . BlobstoreServiceError . INTERNAL_ERROR : InternalError , blobstore_service_pb . BlobstoreServiceError . BLOB_NOT_FOUND : BlobNotFoundError , blobstore_service_pb . BlobstoreServiceError . DATA_INDEX_OUT_OF_RANGE : DataIndexOutOfRangeError , blobstore_service_pb . BlobstoreServiceError . BLOB_FETCH_SIZE_TOO_LARGE : BlobFetchSizeTooLargeError , blobstore_service_pb . BlobstoreServiceError . PERMISSION_DENIED : PermissionDeniedError } desired_exc = error_map . get ( error . application_error ) return ( desired_exc ( error . error_detail ) if desired_exc else error )
translate an application error to a datastore error .