import importlib


def import_module(module, package=None):
    """Protected import of a module
    """
    try:
        ret = importlib.import_module(module, package=package)
    except ModuleNotFoundError:
        if package is not None:
            raise ModuleNotFoundError("Requested module/package '{}/{}' not found.".format(module, package))
        raise ModuleNotFoundError("Requested module '{}' not found.".format(module))
    return ret