import {ReportError, MessageName, formatUtils} from '@yarnpkg/core';
import {OperationReporter} from "./operation-reporter";


export class ErrorOperationReporter extends OperationReporter {
    reportOperation(): void {
        const {operation, target, formattedFields, workspace: {project: {configuration}}} = this;

        const error = new ReportError(MessageName.UNNAMED, formatUtils.pretty(configuration, `Unable to ${operation} ${formattedFields.dependency} because ${target} are sealed in ${formattedFields.workspace}.`, 'red'));
        error.stack = undefined;
        throw error;
    }

}