    def solve(self, tokens, wanted_key):
        """Get validated value or raise error."""
        try:
            if not tokens:
                # Having no tokens is allowed by grammar but refused by all
                # properties and expanders.
                raise InvalidValues('no value')
            return self.validate(tokens, wanted_key)
        except InvalidValues as exc:
            if self._reported_error:
                raise exc
            source_line = self.tokens[0].source_line
            source_column = self.tokens[0].source_column
            value = ' '.join(token.serialize() for token in tokens)
            message = (exc.args and exc.args[0]) or 'invalid value'
            LOGGER.warning(
                'Ignored `%s: %s` at %d:%d, %s.',
                self.name, value, source_line, source_column, message)
            self._reported_error = True
            raise exc
Get validated value or raise error.
weasyprint/css/utils.py