# Buggy code
def print_unexpected_error_message(e):
    # bomb = "\U0001F4A3 "
    # explosion = "\U0001F4A5 "
    # fire = "\U0001F525 "
    # print("%s  %s  %s" % (3*bomb, 3*explosion, 3*fire))
    traceback = format_exc()

    stderrlogger = getLogger("stderr")

    from conda.base.context import context

    if context.json:
        from conda.cli.common import stdout_json

        stdout_json(dict(error=traceback))
    else:
        message = """\
An unexpected error has occurred.
Please consider posting the following information to the
conda GitHub issue tracker at:

    https://github.com/conda/conda/issues

"""
        stderrlogger.info(message)
        command = " ".join(sys.argv)
        if " info" not in command:
            # get and print `conda info`
            info_stdout, info_stderr = get_info()
            stderrlogger.info(info_stdout if info_stdout else info_stderr)
        stderrlogger.info("`$ {0}`".format(command))
        stderrlogger.info("\n")
        stderrlogger.info("\n".join("    " + line for line in traceback.splitlines()))


# Traceback (ImportError)
$ conda -h
An unexpected error has occurred.
Please consider posting the following information to the
conda GitHub issue tracker at:

https://github.com/conda/conda/issues



Traceback (most recent call last):
File "/home/vmrguser/anaconda2/bin/conda", line 6, in <module>
sys.exit(conda.cli.main())
File "/home/vmrguser/anaconda2/lib/python2.7/site-packages/conda/cli/main.py", line 164, in main
return conda_exception_handler(_main, *args)
File "/home/vmrguser/anaconda2/lib/python2.7/site-packages/conda/exceptions.py", line 589, in conda_exception_handler
print_unexpected_error_message(e)
File "/home/vmrguser/anaconda2/lib/python2.7/site-packages/conda/exceptions.py", line 543, in print_unexpected_error_message
info_stdout, info_stderr = get_info()
File "/home/vmrguser/anaconda2/lib/python2.7/site-packages/conda/exceptions.py", line 513, in get_info
args.func(args, p)
File "/home/vmrguser/anaconda2/lib/python2.7/site-packages/conda/cli/main_info.py", line 148, in execute
from conda.api import get_index
File "/home/vmrguser/anaconda2/lib/python2.7/site-packages/conda/api.py", line 1, in <module>
from .core.index import get_index
File "/home/vmrguser/anaconda2/lib/python2.7/site-packages/conda/core/index.py", line 9, in <module>
from .repodata import collect_all_repodata
File "/home/vmrguser/anaconda2/lib/python2.7/site-packages/conda/core/repodata.py", line 21, in <module>
from requests.packages.urllib3.exceptions import InsecureRequestWarning
ImportError: No module named packages.urllib3.exceptions

# Fixed code
def print_unexpected_error_message(e):
    # bomb = "\U0001F4A3 "
    # explosion = "\U0001F4A5 "
    # fire = "\U0001F525 "
    # print("%s  %s  %s" % (3*bomb, 3*explosion, 3*fire))
    traceback = format_exc()

    stderrlogger = getLogger("stderr")

    from .base.context import context

    if context.json:
        from .cli.common import stdout_json

        stdout_json(dict(error=traceback))
    else:
        message = """\
An unexpected error has occurred.
Please consider posting the following information to the
conda GitHub issue tracker at:

    https://github.com/conda/conda/issues

"""
        stderrlogger.info(message)
        command = " ".join(sys.argv)
        if " info" not in command:
            from .cli.main_info import get_info_dict, get_main_info_str

            stderrlogger.info(get_main_info_str(get_info_dict()))
        stderrlogger.info("`$ {0}`".format(command))
        stderrlogger.info("\n")
        stderrlogger.info("\n".join("    " + line for line in traceback.splitlines()))