Remove "/" sign in AbstractRestconfStreamRegistry
[netconf.git] / restconf / restconf-nb / src / main / java / org / opendaylight / restconf / server / api / ServerError.java
1 /*
2  * Copyright (c) 2024 PANTHEON.tech, s.r.o. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.restconf.server.api;
9
10 import static java.util.Objects.requireNonNull;
11
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;
18
19 /**
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}.
23  *
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
30  */
31 @NonNullByDefault
32 public record ServerError(
33         ErrorType type,
34         ErrorTag tag,
35         @Nullable ErrorMessage message,
36         @Nullable String appTag,
37         @Nullable ServerErrorPath path,
38         @Nullable ServerErrorInfo info) {
39     public ServerError {
40         requireNonNull(type);
41         requireNonNull(tag);
42     }
43
44     public ServerError(final ErrorType type, final ErrorTag tag, final String message) {
45         this(type, tag, new ErrorMessage(message), null, null, null);
46     }
47
48     @Override
49     public String toString() {
50         return MoreObjects.toStringHelper(this).omitNullValues()
51             .add("type", type)
52             .add("tag", tag)
53             .add("appTag", appTag)
54             .add("message", message)
55             .add("path", path)
56             .add("info", info)
57             .toString();
58     }
59 }