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.server.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;
15 import org.opendaylight.restconf.api.ErrorMessage;
16 import org.opendaylight.yangtools.yang.common.ErrorTag;
17 import org.opendaylight.yangtools.yang.common.ErrorType;
20 * Encapsulates a single {@code error} within the
21 * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-3.9">"errors" YANG Data Template</a> as bound to a particular
22 * {@link DatabindContext}.
24 * @param type value of {@code error-type} leaf
25 * @param tag value of {@code error-tag} leaf
26 * @param message value of {@code error-message} leaf, potentially with metadata
27 * @param appTag value of {@code error-api-tag} leaf
28 * @param path optional {@code error-path} leaf
29 * @param info optional content of {@code error-info} anydata
32 public record ServerError(
35 @Nullable ErrorMessage message,
36 @Nullable String appTag,
37 @Nullable ServerErrorPath path,
38 @Nullable ServerErrorInfo info) {
44 public ServerError(final ErrorType type, final ErrorTag tag, final String message) {
45 this(type, tag, new ErrorMessage(message), null, null, null);
49 public String toString() {
50 return MoreObjects.toStringHelper(this).omitNullValues()
53 .add("appTag", appTag)
54 .add("message", message)