mirror of
https://mau.dev/maunium/synapse.git
synced 2024-12-15 10:23:53 +01:00
Cast errors generated during synapse_port_db to str (#8585)
I noticed in https://github.com/matrix-org/synapse/issues/8575 that the `end_error` variable in `synapse_port_db` is set to an `Exception`, even though later we expect it to be a `str`.
This PR simply casts an exception raised to a string. I'm doing this instead of having `end_error` be of type exception as we explicitly set `end_error` to a str here:
d25eb8f370/scripts/synapse_port_db (L542-L547)
This whole file could probably use some heavy refactoring, but until then at least this fix will prevent exception contents from being hidden from us and users.
This commit is contained in:
parent
626b8f0846
commit
a312e890f5
2 changed files with 4 additions and 2 deletions
1
changelog.d/8585.bugfix
Normal file
1
changelog.d/8585.bugfix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Fix a bug that prevented errors encountered during execution of the `synapse_port_db` from being correctly printed.
|
|
@ -22,6 +22,7 @@ import logging
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
|
@ -152,7 +153,7 @@ IGNORED_TABLES = {
|
||||||
|
|
||||||
# Error returned by the run function. Used at the top-level part of the script to
|
# Error returned by the run function. Used at the top-level part of the script to
|
||||||
# handle errors and return codes.
|
# handle errors and return codes.
|
||||||
end_error = None
|
end_error = None # type: Optional[str]
|
||||||
# The exec_info for the error, if any. If error is defined but not exec_info the script
|
# The exec_info for the error, if any. If error is defined but not exec_info the script
|
||||||
# will show only the error message without the stacktrace, if exec_info is defined but
|
# will show only the error message without the stacktrace, if exec_info is defined but
|
||||||
# not the error then the script will show nothing outside of what's printed in the run
|
# not the error then the script will show nothing outside of what's printed in the run
|
||||||
|
@ -635,7 +636,7 @@ class Porter(object):
|
||||||
self.progress.done()
|
self.progress.done()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
global end_error_exec_info
|
global end_error_exec_info
|
||||||
end_error = e
|
end_error = str(e)
|
||||||
end_error_exec_info = sys.exc_info()
|
end_error_exec_info = sys.exc_info()
|
||||||
logger.exception("")
|
logger.exception("")
|
||||||
finally:
|
finally:
|
||||||
|
|
Loading…
Reference in a new issue