Use baseexception

main
Bob Mottram 2024-02-07 15:09:54 +00:00
parent b8372aa02e
commit 28f3082c4b
3 changed files with 14 additions and 14 deletions

View File

@ -484,7 +484,7 @@ def load_document(url):
return None
except JsonLdError as ex:
raise ex
except Exception as cause:
except BaseException as cause:
raise JsonLdError(
'Could not retrieve a JSON-LD document from the URL.',
'jsonld.LoadDocumentError', code='loading document failed',
@ -847,7 +847,7 @@ class JsonLdProcessor(object):
'jsonld.NullRemoteDocument')
if _is_string(remote_doc['document']):
remote_doc['document'] = json.loads(remote_doc['document'])
except Exception as cause:
except BaseException as cause:
raise JsonLdError(
'Could not retrieve a JSON-LD document from the URL.',
'jsonld.LoadDocumentError',
@ -872,7 +872,7 @@ class JsonLdProcessor(object):
try:
self._retrieve_context_urls(
input_, {}, options['documentLoader'], options['base'])
except Exception as cause:
except BaseException as cause:
raise JsonLdError(
'Could not perform JSON-LD expansion.',
'jsonld.ExpandError', cause=cause)
@ -925,7 +925,7 @@ class JsonLdProcessor(object):
try:
# expand input
expanded = self.expand(input_, options)
except Exception as cause:
except BaseException as cause:
raise JsonLdError(
'Could not expand input before flattening.',
'jsonld.FlattenError', cause=cause)
@ -941,7 +941,7 @@ class JsonLdProcessor(object):
options['skipExpansion'] = True
try:
compacted = self.compact(flattened, ctx, options)
except Exception as cause:
except BaseException as cause:
raise JsonLdError(
'Could not compact flattened output.',
'jsonld.FlattenError', cause=cause)
@ -994,7 +994,7 @@ class JsonLdProcessor(object):
'jsonld.NullRemoteDocument')
if _is_string(remote_frame['document']):
remote_frame['document'] = json.loads(remote_frame['document'])
except Exception as cause:
except BaseException as cause:
raise JsonLdError(
'Could not retrieve a JSON-LD document from the URL.',
'jsonld.LoadDocumentError',
@ -1218,7 +1218,7 @@ class JsonLdProcessor(object):
try:
self._retrieve_context_urls(
local_ctx, {}, options['documentLoader'], options['base'])
except Exception as cause:
except BaseException as cause:
raise JsonLdError(
'Could not process JSON-LD context.',
'jsonld.ContextError', cause=cause)
@ -4399,7 +4399,7 @@ class JsonLdProcessor(object):
try:
remote_doc = load_document(url)
ctx = remote_doc['document']
except Exception as cause:
except BaseException as cause:
raise JsonLdError(
'Dereferencing a URL did not result in a valid JSON-LD '
'context.',
@ -4410,7 +4410,7 @@ class JsonLdProcessor(object):
if _is_string(ctx):
try:
ctx = json.loads(ctx)
except Exception as cause:
except BaseException as cause:
raise JsonLdError(
'Could not parse JSON from URL.',
'jsonld.ParseError', {'url': url},

View File

@ -25,7 +25,7 @@ class thread_with_trace(threading.Thread):
threading.Thread.__init__(self, *self._args, **self._keywords)
self.killed = False
break
except Exception as ex:
except BaseException as ex:
print('ERROR: threads.py/__init__ failed - ' + str(ex))
time.sleep(1)
tries += 1
@ -38,7 +38,7 @@ class thread_with_trace(threading.Thread):
self.run = self.__run
threading.Thread.start(self)
break
except Exception as ex:
except BaseException as ex:
print('ERROR: threads.py/start failed - ' + str(ex))
time.sleep(1)
tries += 1
@ -54,7 +54,7 @@ class thread_with_trace(threading.Thread):
# try:
self.__run_backup()
self.run = self.__run_backup
# except Exception as ex:
# except BaseException as ex:
# print('ERROR: threads.py/__run failed - ' + str(ex) +
# ', ' + str(self.__run_backup))

View File

@ -106,7 +106,7 @@ def webfinger_handle(session, handle: str, http_prefix: str,
result = \
get_json(signing_priv_key_pem, session, url, hdr, par,
debug, project_version, http_prefix, from_domain)
except Exception as ex:
except BaseException as ex:
print('ERROR: webfinger_handle ' + wf_handle + ' ' + str(ex))
return None
@ -126,7 +126,7 @@ def webfinger_handle(session, handle: str, http_prefix: str,
result = \
get_json(signing_priv_key_pem, session, url, hdr, par,
debug, project_version, http_prefix, from_domain)
except Exception as ex:
except BaseException as ex:
print('ERROR: webfinger_handle ' + wf_handle + ' ' + str(ex))
return None