Helper method provided because we actually can't put that in the constructor, it creates a bug in Nose tests
        https://github.com/nose-devs/nose/issues/725

        :param parser:
        :param desired_type:
        :param obj:
        :param caught:
        :param options:
        :return:

def create_for_caught_error(parser: _BaseParserDeclarationForRegistries, desired_type: Type[T],
                                obj: PersistedObject, caught: Exception, options: Dict[str, Dict[str, Any]]):
        """
        Helper method provided because we actually can't put that in the constructor, it creates a bug in Nose tests
        https://github.com/nose-devs/nose/issues/725

        :param parser:
        :param desired_type:
        :param obj:
        :param caught:
        :param options:
        :return:
        """
        try:
            typ = get_pretty_type_str(desired_type)
        except:
            typ = str(desired_type)

        e = ParsingException('Error while parsing ' + str(obj) + ' as a ' + typ + ' with parser \''
                                + str(parser) + '\' using options=(' + str(options) + ') : caught \n  '
                                + str(caught.__class__.__name__) + ' : ' + str(caught))\
            .with_traceback(caught.__traceback__) # 'from e' was hiding the inner traceback. This is much better for debug
        e.__cause__ = None
        # e.__cause__ = caught
        # store the exception still, to be able to handle it later
        e.caught = caught
        return e