mirror of
https://github.com/certbot/certbot.git
synced 2026-05-28 04:34:11 -04:00
Merge pull request #3068 from TheNavigat/dialogerror
Display DialogError details correctly
This commit is contained in:
commit
568df2108e
2 changed files with 13 additions and 1 deletions
|
|
@ -1,6 +1,7 @@
|
|||
"""Certbot main entry point."""
|
||||
from __future__ import print_function
|
||||
import atexit
|
||||
import dialog
|
||||
import errno
|
||||
import functools
|
||||
import logging.handlers
|
||||
|
|
@ -674,7 +675,10 @@ def _handle_exception(exc_type, exc_value, trace, config):
|
|||
# Here we're passing a client or ACME error out to the client at the shell
|
||||
# Tell the user a bit about what happened, without overwhelming
|
||||
# them with a full traceback
|
||||
err = traceback.format_exception_only(exc_type, exc_value)[0]
|
||||
if issubclass(exc_type, dialog.error):
|
||||
err = exc_value.complete_message()
|
||||
else:
|
||||
err = traceback.format_exception_only(exc_type, exc_value)[0]
|
||||
# Typical error from the ACME module:
|
||||
# acme.messages.Error: urn:acme:error:malformed :: The request message was
|
||||
# malformed :: Error creating new registration :: Validation of contact
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
from __future__ import print_function
|
||||
|
||||
import argparse
|
||||
import dialog
|
||||
import functools
|
||||
import itertools
|
||||
import os
|
||||
|
|
@ -922,6 +923,13 @@ class CLITest(unittest.TestCase): # pylint: disable=too-many-public-methods
|
|||
mock_sys.exit.assert_called_with(''.join(
|
||||
traceback.format_exception_only(KeyboardInterrupt, interrupt)))
|
||||
|
||||
# Test dialog errors
|
||||
exception = dialog.error(message="test message")
|
||||
main._handle_exception(
|
||||
dialog.DialogError, exc_value=exception, trace=None, config=None)
|
||||
error_msg = mock_sys.exit.call_args_list[-1][0][0]
|
||||
self.assertTrue("test message" in error_msg)
|
||||
|
||||
def test_read_file(self):
|
||||
rel_test_path = os.path.relpath(os.path.join(self.tmp_dir, 'foo'))
|
||||
self.assertRaises(
|
||||
|
|
|
|||
Loading…
Reference in a new issue