@Override
    public String toString() {
        StringBuilder message = new StringBuilder();
        SourceLocation lastLoc = SourceLocation.none();
        for (int i = contexts.size() - 1; i >= 0; i--) {
            Pair<String, SourceLocation> context = contexts.get(i);
            message.append(context.left);
            message.append(System.lineSeparator());
            if (context.right != SourceLocation.NONE && context.right != lastLoc) {
                message.append("  at ")
                        .append(context.right.getSourceLocation().getFilename())
                        .append(":")
                        .append(context.right.getSourceLocation().getLine())
                        .append(System.lineSeparator());
                lastLoc = context.right;
            }
        }

        message.append(root.getMessageWithoutLocation());
        if (root.getSourceLocation() != SourceLocation.none() && root.getSourceLocation() != lastLoc) {
            message.append(System.lineSeparator())
                    .append("  at ")
                    .append(root.getSourceLocation().getFilename())
                    .append(":")
                    .append(root.getSourceLocation().getLine());
        }
        return message.toString();
    }
Sets a piece of context on this error.

@param context the context to add to the error.
@param location the source location of the context being added.
@return returns this error with the added context.
smithy-rules-engine/src/main/java/software/amazon/smithy/rulesengine/language/error/RuleError.java