public function resolveWidgetErrorMessage(ResolveWidgetErrorMessageEvent $event)
    {
        if (!$this->scopeDeterminator->currentScopeIsBackend()) {
            return;
        }

        $error = $event->getError();

        if ($error instanceof \Exception) {
            $event->setError($error->getMessage());
        } elseif (\is_object($error)) {
            if (\method_exists($error, '__toString')) {
                $event->setError((string) $error);
            } else {
                $event->setError(\sprintf('[%s]', \get_class($error)));
            }
        } elseif (!\is_string($error)) {
            $event->setError(\sprintf('[%s]', \gettype($error)));
        }
    }