Better handling of errors and exceptions when new view name already
exists
This commit is contained in:
@ -6,3 +6,4 @@ cdef extern from "obierrno.h":
|
||||
|
||||
extern int OBI_LINE_IDX_ERROR
|
||||
extern int OBI_ELT_IDX_ERROR
|
||||
extern int OBIVIEW_ALREADY_EXISTS_ERROR
|
||||
|
@ -22,6 +22,9 @@ from obitools3.apps.config import getConfiguration,logger
|
||||
from obitools3.apps.temp import get_temp_dms
|
||||
from obitools3.utils cimport tobytes # TODO because can't read options as bytes
|
||||
|
||||
from obitools3.dms.capi.obierrno cimport obi_errno, \
|
||||
OBIVIEW_ALREADY_EXISTS_ERROR
|
||||
|
||||
|
||||
class MalformedURIException(RuntimeError):
|
||||
pass
|
||||
@ -219,10 +222,13 @@ def open_uri(uri,
|
||||
type(resource[1]),
|
||||
urlunparse(urip))
|
||||
except Exception as e:
|
||||
global obi_errno
|
||||
if obi_errno == OBIVIEW_ALREADY_EXISTS_ERROR:
|
||||
raise Exception("View name already exists in this DMS")
|
||||
error=e
|
||||
|
||||
if scheme==b"dms" :
|
||||
logger('Error','cannot open DMS: %s', uri)
|
||||
logger('Error','Could not open DMS URI: %s', uri)
|
||||
raise FileNotFoundError('uri')
|
||||
|
||||
if not urip.scheme:
|
||||
|
Reference in New Issue
Block a user