showErrors(errors, triggerEvent) {
        this.loading = false;
        if (!Array.isArray(errors)) {
            errors = [errors];
        }

        if (Array.isArray(this.errors)) {
            errors = _.union(errors, this.errors);
        }

        errors = errors.concat(this.customErrors).filter((err) => !!err);

        if (!errors.length) {
            this.setAlert(false);
            return;
        }

        // Mark any components as invalid if in a custom message.
        const componentErrors = {};
        errors.forEach((err) => {
            const path = err.path || err.context?.path || err.component?.key;
            if (!componentErrors[path]) {
                componentErrors[path] = [];
            }
            componentErrors[path].push(err);
        });

        // Iterate through all of our component errors and apply them to the components.
        for (let path in componentErrors) {
            const component = this.getComponent(path);
            const errors = componentErrors[path];
            if (component) {
                component.serverErrors = errors.filter((err) => err.fromServer);
                component.setCustomValidity(errors, true)
            }
        }

        const displayedErrors = [];
        if (errors.length) {
            errors = _.uniqBy(errors, (error) => [error.message, error.component?.id, error.context?.path].join());
            const createListItem = (message, index) => {
                const err = errors[index];
                const messageFromIndex = !_.isUndefined(index) && errors && errors[index];
                const keyOrPath =
                    messageFromIndex?.formattedKeyOrPath ||
                    messageFromIndex?.path ||
                    messageFromIndex?.context?.path ||
                    (err.context?.component && err.context?.component.key) ||
                    (err.component && err.component.key) ||
                    (err.fromServer && err.path);

                const formattedKeyOrPath = keyOrPath ? getStringFromComponentPath(keyOrPath) : '';
                if (typeof err !== 'string' && !err.formattedKeyOrPath) {
                    err.formattedKeyOrPath = formattedKeyOrPath;
                }

                return {
                    message: unescapeHTML(message),
                    keyOrPath: formattedKeyOrPath,
                };
            };

            errors.forEach(({ message, context, fromServer, component }, index) => {
                const text =
                    !component?.label || context?.hasLabel || fromServer
                        ? this.t(message)
                        : `${this.t(component?.label)}: ${this.t(message)}`;
                displayedErrors.push(createListItem(text, index));
            });
        }

        const errorsList = this.renderTemplate('errorsList', { errors: displayedErrors });
        this.root.setAlert('danger', errorsList);
        if (triggerEvent) {
            this.emit('error', errors);
        }

        return errors;
    }
@param {Array} errors - An array of errors to display.
@param {boolean} triggerEvent - Whether or not to trigger the error event.
@returns {void|Array} - The errors that were set.