import traceback
import sys

try:
    from StringIO import StringIO
except:
    from io import StringIO


class InnerException(Exception):
    def __init__(self, inner_exception):
        self.inner_exception = inner_exception
        f = StringIO()
        exc_type, exc_value, exc_traceback = sys.exc_info()
        traceback.print_exception(exc_type, exc_value, exc_traceback, file=f)
        self.inner_stack_trace = f.getvalue()
        print(self.inner_stack_trace)

    def __str__(self):
        s = super(InnerException, self).__str__()
        s += "\n"
        s += "Inner Exception:\n"
        s += self.inner_stack_trace
        return s
