X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=protocol%2Frestconf-api%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Frestconf%2Fapi%2FErrorMessage.java;fp=protocol%2Frestconf-api%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Frestconf%2Fapi%2FErrorMessage.java;h=19d18ec151d1e20fe7a63f46309c6b5f4a23c0ea;hb=1168cbc3b3ae493f05d73a7d02ab69ba35cc055e;hp=0000000000000000000000000000000000000000;hpb=4007ec19eed842466aaac39a4f65b5c36c624a31;p=netconf.git diff --git a/protocol/restconf-api/src/main/java/org/opendaylight/restconf/api/ErrorMessage.java b/protocol/restconf-api/src/main/java/org/opendaylight/restconf/api/ErrorMessage.java new file mode 100644 index 0000000000..19d18ec151 --- /dev/null +++ b/protocol/restconf-api/src/main/java/org/opendaylight/restconf/api/ErrorMessage.java @@ -0,0 +1,43 @@ +/* + * 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(); + } +} \ No newline at end of file