mirror of https://gitlab.com/bashrc2/epicyon
Use baseexception
parent
b8372aa02e
commit
28f3082c4b
18
pyjsonld.py
18
pyjsonld.py
|
@ -484,7 +484,7 @@ def load_document(url):
|
||||||
return None
|
return None
|
||||||
except JsonLdError as ex:
|
except JsonLdError as ex:
|
||||||
raise ex
|
raise ex
|
||||||
except Exception as cause:
|
except BaseException as cause:
|
||||||
raise JsonLdError(
|
raise JsonLdError(
|
||||||
'Could not retrieve a JSON-LD document from the URL.',
|
'Could not retrieve a JSON-LD document from the URL.',
|
||||||
'jsonld.LoadDocumentError', code='loading document failed',
|
'jsonld.LoadDocumentError', code='loading document failed',
|
||||||
|
@ -847,7 +847,7 @@ class JsonLdProcessor(object):
|
||||||
'jsonld.NullRemoteDocument')
|
'jsonld.NullRemoteDocument')
|
||||||
if _is_string(remote_doc['document']):
|
if _is_string(remote_doc['document']):
|
||||||
remote_doc['document'] = json.loads(remote_doc['document'])
|
remote_doc['document'] = json.loads(remote_doc['document'])
|
||||||
except Exception as cause:
|
except BaseException as cause:
|
||||||
raise JsonLdError(
|
raise JsonLdError(
|
||||||
'Could not retrieve a JSON-LD document from the URL.',
|
'Could not retrieve a JSON-LD document from the URL.',
|
||||||
'jsonld.LoadDocumentError',
|
'jsonld.LoadDocumentError',
|
||||||
|
@ -872,7 +872,7 @@ class JsonLdProcessor(object):
|
||||||
try:
|
try:
|
||||||
self._retrieve_context_urls(
|
self._retrieve_context_urls(
|
||||||
input_, {}, options['documentLoader'], options['base'])
|
input_, {}, options['documentLoader'], options['base'])
|
||||||
except Exception as cause:
|
except BaseException as cause:
|
||||||
raise JsonLdError(
|
raise JsonLdError(
|
||||||
'Could not perform JSON-LD expansion.',
|
'Could not perform JSON-LD expansion.',
|
||||||
'jsonld.ExpandError', cause=cause)
|
'jsonld.ExpandError', cause=cause)
|
||||||
|
@ -925,7 +925,7 @@ class JsonLdProcessor(object):
|
||||||
try:
|
try:
|
||||||
# expand input
|
# expand input
|
||||||
expanded = self.expand(input_, options)
|
expanded = self.expand(input_, options)
|
||||||
except Exception as cause:
|
except BaseException as cause:
|
||||||
raise JsonLdError(
|
raise JsonLdError(
|
||||||
'Could not expand input before flattening.',
|
'Could not expand input before flattening.',
|
||||||
'jsonld.FlattenError', cause=cause)
|
'jsonld.FlattenError', cause=cause)
|
||||||
|
@ -941,7 +941,7 @@ class JsonLdProcessor(object):
|
||||||
options['skipExpansion'] = True
|
options['skipExpansion'] = True
|
||||||
try:
|
try:
|
||||||
compacted = self.compact(flattened, ctx, options)
|
compacted = self.compact(flattened, ctx, options)
|
||||||
except Exception as cause:
|
except BaseException as cause:
|
||||||
raise JsonLdError(
|
raise JsonLdError(
|
||||||
'Could not compact flattened output.',
|
'Could not compact flattened output.',
|
||||||
'jsonld.FlattenError', cause=cause)
|
'jsonld.FlattenError', cause=cause)
|
||||||
|
@ -994,7 +994,7 @@ class JsonLdProcessor(object):
|
||||||
'jsonld.NullRemoteDocument')
|
'jsonld.NullRemoteDocument')
|
||||||
if _is_string(remote_frame['document']):
|
if _is_string(remote_frame['document']):
|
||||||
remote_frame['document'] = json.loads(remote_frame['document'])
|
remote_frame['document'] = json.loads(remote_frame['document'])
|
||||||
except Exception as cause:
|
except BaseException as cause:
|
||||||
raise JsonLdError(
|
raise JsonLdError(
|
||||||
'Could not retrieve a JSON-LD document from the URL.',
|
'Could not retrieve a JSON-LD document from the URL.',
|
||||||
'jsonld.LoadDocumentError',
|
'jsonld.LoadDocumentError',
|
||||||
|
@ -1218,7 +1218,7 @@ class JsonLdProcessor(object):
|
||||||
try:
|
try:
|
||||||
self._retrieve_context_urls(
|
self._retrieve_context_urls(
|
||||||
local_ctx, {}, options['documentLoader'], options['base'])
|
local_ctx, {}, options['documentLoader'], options['base'])
|
||||||
except Exception as cause:
|
except BaseException as cause:
|
||||||
raise JsonLdError(
|
raise JsonLdError(
|
||||||
'Could not process JSON-LD context.',
|
'Could not process JSON-LD context.',
|
||||||
'jsonld.ContextError', cause=cause)
|
'jsonld.ContextError', cause=cause)
|
||||||
|
@ -4399,7 +4399,7 @@ class JsonLdProcessor(object):
|
||||||
try:
|
try:
|
||||||
remote_doc = load_document(url)
|
remote_doc = load_document(url)
|
||||||
ctx = remote_doc['document']
|
ctx = remote_doc['document']
|
||||||
except Exception as cause:
|
except BaseException as cause:
|
||||||
raise JsonLdError(
|
raise JsonLdError(
|
||||||
'Dereferencing a URL did not result in a valid JSON-LD '
|
'Dereferencing a URL did not result in a valid JSON-LD '
|
||||||
'context.',
|
'context.',
|
||||||
|
@ -4410,7 +4410,7 @@ class JsonLdProcessor(object):
|
||||||
if _is_string(ctx):
|
if _is_string(ctx):
|
||||||
try:
|
try:
|
||||||
ctx = json.loads(ctx)
|
ctx = json.loads(ctx)
|
||||||
except Exception as cause:
|
except BaseException as cause:
|
||||||
raise JsonLdError(
|
raise JsonLdError(
|
||||||
'Could not parse JSON from URL.',
|
'Could not parse JSON from URL.',
|
||||||
'jsonld.ParseError', {'url': url},
|
'jsonld.ParseError', {'url': url},
|
||||||
|
|
|
@ -25,7 +25,7 @@ class thread_with_trace(threading.Thread):
|
||||||
threading.Thread.__init__(self, *self._args, **self._keywords)
|
threading.Thread.__init__(self, *self._args, **self._keywords)
|
||||||
self.killed = False
|
self.killed = False
|
||||||
break
|
break
|
||||||
except Exception as ex:
|
except BaseException as ex:
|
||||||
print('ERROR: threads.py/__init__ failed - ' + str(ex))
|
print('ERROR: threads.py/__init__ failed - ' + str(ex))
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
tries += 1
|
tries += 1
|
||||||
|
@ -38,7 +38,7 @@ class thread_with_trace(threading.Thread):
|
||||||
self.run = self.__run
|
self.run = self.__run
|
||||||
threading.Thread.start(self)
|
threading.Thread.start(self)
|
||||||
break
|
break
|
||||||
except Exception as ex:
|
except BaseException as ex:
|
||||||
print('ERROR: threads.py/start failed - ' + str(ex))
|
print('ERROR: threads.py/start failed - ' + str(ex))
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
tries += 1
|
tries += 1
|
||||||
|
@ -54,7 +54,7 @@ class thread_with_trace(threading.Thread):
|
||||||
# try:
|
# try:
|
||||||
self.__run_backup()
|
self.__run_backup()
|
||||||
self.run = self.__run_backup
|
self.run = self.__run_backup
|
||||||
# except Exception as ex:
|
# except BaseException as ex:
|
||||||
# print('ERROR: threads.py/__run failed - ' + str(ex) +
|
# print('ERROR: threads.py/__run failed - ' + str(ex) +
|
||||||
# ', ' + str(self.__run_backup))
|
# ', ' + str(self.__run_backup))
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,7 @@ def webfinger_handle(session, handle: str, http_prefix: str,
|
||||||
result = \
|
result = \
|
||||||
get_json(signing_priv_key_pem, session, url, hdr, par,
|
get_json(signing_priv_key_pem, session, url, hdr, par,
|
||||||
debug, project_version, http_prefix, from_domain)
|
debug, project_version, http_prefix, from_domain)
|
||||||
except Exception as ex:
|
except BaseException as ex:
|
||||||
print('ERROR: webfinger_handle ' + wf_handle + ' ' + str(ex))
|
print('ERROR: webfinger_handle ' + wf_handle + ' ' + str(ex))
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ def webfinger_handle(session, handle: str, http_prefix: str,
|
||||||
result = \
|
result = \
|
||||||
get_json(signing_priv_key_pem, session, url, hdr, par,
|
get_json(signing_priv_key_pem, session, url, hdr, par,
|
||||||
debug, project_version, http_prefix, from_domain)
|
debug, project_version, http_prefix, from_domain)
|
||||||
except Exception as ex:
|
except BaseException as ex:
|
||||||
print('ERROR: webfinger_handle ' + wf_handle + ' ' + str(ex))
|
print('ERROR: webfinger_handle ' + wf_handle + ' ' + str(ex))
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue