Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit a312e89

Browse files
Cast errors generated during synapse_port_db to str (#8585)
I noticed in #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: https://github.com/matrix-org/synapse/blob/d25eb8f3709965d0face01a041d5292490bf0139/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.
1 parent 626b8f0 commit a312e89

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

changelog.d/8585.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix a bug that prevented errors encountered during execution of the `synapse_port_db` from being correctly printed.

scripts/synapse_port_db

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import logging
2222
import sys
2323
import time
2424
import traceback
25+
from typing import Optional
2526

2627
import yaml
2728

@@ -152,7 +153,7 @@ IGNORED_TABLES = {
152153

153154
# Error returned by the run function. Used at the top-level part of the script to
154155
# handle errors and return codes.
155-
end_error = None
156+
end_error = None # type: Optional[str]
156157
# The exec_info for the error, if any. If error is defined but not exec_info the script
157158
# will show only the error message without the stacktrace, if exec_info is defined but
158159
# not the error then the script will show nothing outside of what's printed in the run
@@ -635,7 +636,7 @@ class Porter(object):
635636
self.progress.done()
636637
except Exception as e:
637638
global end_error_exec_info
638-
end_error = e
639+
end_error = str(e)
639640
end_error_exec_info = sys.exc_info()
640641
logger.exception("")
641642
finally:

0 commit comments

Comments
 (0)