def cast(self, value, **opts):
        """Convert the given value to the target type.

        Return ``None`` if the value is empty. If an error occurs,
        raise a ``ConverterError``.
        """
        if isinstance(value, self.result_type):
            return value
        if self._is_null(value):
            return None
        try:
            opts_ = self.opts.copy()
            opts_.update(opts)
            return self._cast(value, **opts_)
        except Exception as e:
            if not isinstance(e, ConverterError):
                e = ConverterError(None, exc=e)
            e.converter = self.__class__
            raise e
Convert the given value to the target type.

        Return ``None`` if the value is empty. If an error occurs,
        raise a ``ConverterError``.