Do not pretty-print body class
[yangtools.git] / data / yang-data-api / src / main / java / org / opendaylight / yangtools / yang / data / api / schema / tree / DataValidationFailedException.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. 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.api.schema.tree;
9
10 import static java.util.Objects.requireNonNull;
11
12 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
13
14 /**
15  * Exception thrown when a proposed change fails validation before being applied into the datastore. This can have
16  * multiple reasons, for example the datastore has been concurrently modified such that a conflicting node is present,
17  * or the modification is structurally incorrect.
18  */
19 public class DataValidationFailedException extends Exception {
20     private static final long serialVersionUID = 1L;
21
22     private final YangInstanceIdentifier path;
23
24     /**
25      * Create a new instance.
26      *
27      * @param path Object path which caused this exception
28      * @param message Specific message describing the failure
29      */
30     public DataValidationFailedException(final YangInstanceIdentifier path, final String message) {
31         this(path, message, null);
32     }
33
34     /**
35      * Create a new instance, initializing the cause.
36      *
37      * @param path Object path which caused this exception
38      * @param message Specific message describing the failure
39      * @param cause Exception which triggered this failure, may be null
40      */
41     public DataValidationFailedException(final YangInstanceIdentifier path, final String message,
42             final Throwable cause) {
43         super(message, cause);
44         this.path = requireNonNull(path);
45     }
46
47     /**
48      * Returns the offending object path.
49      *
50      * @return Path of the offending object
51      */
52     public YangInstanceIdentifier getPath() {
53         return path;
54     }
55 }