我在我的应用中有这个代码:
//Picked user.
for (UserList selected : selectedUsers) {
GroupMembers member = new GroupMembers();
member.setName(selected.getName());
member.setUsername(selected.getUsername());
member.setEmail(selected.getEmail());
member.setUid(selected.getUid());
mGroupMembers.add(member);
mPickedText.setText("Selected: " + selected.getName());
}
当我的MongoDB出现故障时,我有这个:
try:
return self.wsgi_app(environ, start_response)
except Exception:
logger.warning('Failed to render the custom %s page', exc.code, exc_info=True)
我不想要有关第一个异常的信息 - 我之前已经记录了我的代码。我只想记录在try / except块内发生的异常(在处理上述异常时出现的另一个异常,发生了另一个异常:)。
如何在try / except块之前重置当前的异常链?
我可以试试:
18:44:55 WARNING Failed to render the custom 500 page
Traceback (most recent call last):
...
File ".../venv/lib/python3.5/site-packages/pymongo/topology.py", line 189, in select_servers
self._error_message(selector))
pymongo.errors.ServerSelectionTimeoutError: localhost:27017: [Errno 61] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
...
pymongo.errors.ServerSelectionTimeoutError: localhost:27017: [Errno 61] Connection refused
但它会破坏可能在try / except中发生的几个例外的有用链。