/* * Copyright (c) 2024 PANTHEON.tech, s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ package org.opendaylight.restconf.api; import static java.util.Objects.requireNonNull; import com.google.common.base.MoreObjects; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; /** * The contents of a {@code error-message} element as defined in * RFC8040 errors grouping. This object can optionally * transport the Language Identification as conveyed via, * for example, RFC6241 error-message element. * * @param elementBody the string to be displayed * @param xmlLang optional Language Identification string */ @NonNullByDefault // TODO: consider sharing this class with netconf-api's NetconfDocumentedException public record ErrorMessage(String elementBody, @Nullable String xmlLang) { public ErrorMessage { requireNonNull(elementBody); } public ErrorMessage(final String elementBody) { this(elementBody, null); } @Override public String toString() { return MoreObjects.toStringHelper(this).omitNullValues() .add("elementBody", elementBody) .add("xmlLang", xmlLang) .toString(); } }