Skip to content

Commit a716019

Browse files
committed
Remove deduplication in msgs
1 parent b4f78c3 commit a716019

1 file changed

Lines changed: 24 additions & 28 deletions

File tree

src/onepassword/desktop_core.py

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,24 @@ def release_client(self, client_id: int):
123123
except Exception as e:
124124
print(f"failed to release client: {e}")
125125

126+
ERR_CHANNEL_CLOSED = (
127+
"desktop app connection channel is closed. "
128+
"Make sure Settings > Developer > Integrate with other apps is enabled, "
129+
"or contact 1Password support"
130+
)
131+
132+
ERR_CONNECTION_DROPPED = (
133+
"connection was unexpectedly dropped by the desktop app. "
134+
"Make sure the desktop app is running and Settings > Developer > "
135+
"Integrate with other apps is enabled, or contact 1Password support"
136+
)
137+
138+
ERR_INTERNAL_FMT = (
139+
"an internal error occurred. Please contact 1Password support "
140+
"and mention the return code: {}"
141+
)
142+
143+
126144
def error_from_return_code(ret_code: int) -> Exception | None:
127145
if ret_code == 0:
128146
return None
@@ -131,37 +149,15 @@ def error_from_return_code(ret_code: int) -> Exception | None:
131149

132150
if is_darwin:
133151
if ret_code == -3:
134-
return RuntimeError(
135-
"desktop app connection channel is closed. "
136-
"Make sure Settings > Developer > Integrate with other apps is enabled, "
137-
"or contact 1Password support"
138-
)
152+
return RuntimeError(ERR_CHANNEL_CLOSED)
139153
elif ret_code == -7:
140-
return RuntimeError(
141-
"connection was unexpectedly dropped by the desktop app. "
142-
"Make sure the desktop app is running and Settings > Developer > "
143-
"Integrate with other apps is enabled, or contact 1Password support"
144-
)
154+
return RuntimeError(ERR_CONNECTION_DROPPED)
145155
else:
146-
return RuntimeError(
147-
f"an internal error occurred. Please contact 1Password support "
148-
f"and mention the return code: {ret_code}"
149-
)
156+
return RuntimeError(ERR_INTERNAL_FMT.format(ret_code))
150157
else:
151158
if ret_code == -2:
152-
return RuntimeError(
153-
"desktop app connection channel is closed. "
154-
"Make sure Settings > Developer > Integrate with other apps is enabled, "
155-
"or contact 1Password support"
156-
)
159+
return RuntimeError(ERR_CHANNEL_CLOSED)
157160
elif ret_code == -5:
158-
return RuntimeError(
159-
"connection was unexpectedly dropped by the desktop app. "
160-
"Make sure the desktop app is running and Settings > Developer > "
161-
"Integrate with other apps is enabled, or contact 1Password support"
162-
)
161+
return RuntimeError(ERR_CONNECTION_DROPPED)
163162
else:
164-
return RuntimeError(
165-
f"an internal error occurred. Please contact 1Password support "
166-
f"and mention the return code: {ret_code}"
167-
)
163+
return RuntimeError(ERR_INTERNAL_FMT.format(ret_code))

0 commit comments

Comments
 (0)