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