2 * Copyright (c) 2024 PANTHEON.tech, s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.restconf.api;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.base.MoreObjects;
13 import org.eclipse.jdt.annotation.NonNullByDefault;
14 import org.eclipse.jdt.annotation.Nullable;
17 * The contents of a {@code error-message} element as defined in
18 * <a href="https://www.rfc-editor.org/rfc/rfc8040#page-83">RFC8040 errors grouping</a>. This object can optionally
19 * transport the <a href="https://www.w3.org/TR/xml/#sec-lang-tag">Language Identification</a> as conveyed via,
20 * for example, <a href="https://www.rfc-editor.org/rfc/rfc6241#page-17">RFC6241 error-message element</a>.
22 * @param elementBody the string to be displayed
23 * @param xmlLang optional Language Identification string
26 // TODO: consider sharing this class with netconf-api's NetconfDocumentedException
27 public record ErrorMessage(String elementBody, @Nullable String xmlLang) {
29 requireNonNull(elementBody);
32 public ErrorMessage(final String elementBody) {
33 this(elementBody, null);
37 public String toString() {
38 return MoreObjects.toStringHelper(this).omitNullValues()
39 .add("elementBody", elementBody)
40 .add("xmlLang", xmlLang)