cc2b7c01cee6d2966b14ff28d06d735f4e31a5f2
[yangtools.git] / data / yang-data-tree-ri / src / main / java / org / opendaylight / yangtools / yang / data / tree / impl / UniqueValidationFailedException.java
1 /*
2  * Copyright (c) 2020 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.yangtools.yang.data.tree.impl;
9
10 import java.util.List;
11 import org.opendaylight.yangtools.yang.common.ErrorSeverity;
12 import org.opendaylight.yangtools.yang.common.ErrorTag;
13 import org.opendaylight.yangtools.yang.common.ErrorType;
14 import org.opendaylight.yangtools.yang.data.api.ImmutableYangNetconfError;
15 import org.opendaylight.yangtools.yang.data.api.YangNetconfError;
16 import org.opendaylight.yangtools.yang.data.api.YangNetconfErrorAware;
17 import org.opendaylight.yangtools.yang.data.tree.api.UniqueConstraintException;
18
19 /**
20  * Exception thrown when unique constraints would be violated and we cannot throw a {@link UniqueConstraintException}.
21  */
22 final class UniqueValidationFailedException extends SchemaValidationFailedException implements YangNetconfErrorAware {
23     private static final long serialVersionUID = 1L;
24
25     UniqueValidationFailedException(final String message) {
26         super(message);
27     }
28
29     @Override
30     public List<YangNetconfError> getNetconfErrors() {
31         return List.of(ImmutableYangNetconfError.builder()
32             .severity(ErrorSeverity.ERROR)
33             .type(ErrorType.APPLICATION)
34             .tag(ErrorTag.OPERATION_FAILED)
35             .appTag("data-not-unique")
36             // FIXME: 8.0.0: we are missing path information which should be filled in here. Constructor call site needs
37             //               to provide that.
38             .build());
39     }
40 }