aboutsummaryrefslogtreecommitdiffstats
path: root/documentapi/src/main/java/com/yahoo/documentapi/DocumentAccessException.java
blob: 083a68864f645630bead176d26e351579eb0152c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.documentapi;

import com.yahoo.documentapi.messagebus.protocol.DocumentProtocol;

import java.util.Set;
import java.util.HashSet;

/**
 * General exception thrown from various methods in the Vespa Document API.
 *
 * @author Einar M R Rosenvinge
 */
public class DocumentAccessException extends RuntimeException {

    private Set<Integer> errorCodes = new HashSet<>();

    public Set<Integer> getErrorCodes() {
        return errorCodes;
    }

    public DocumentAccessException() {
        super();
    }

    public DocumentAccessException(String message) {
        super(message);
    }

    public DocumentAccessException(String message, Set<Integer> errorCodes) {
        super(message);
        this.errorCodes = errorCodes;
    }

    public boolean hasConditionNotMetError(){
        return errorCodes.contains(DocumentProtocol.ERROR_TEST_AND_SET_CONDITION_FAILED);
    }

    public DocumentAccessException(String message, Throwable cause) {
        super(message, cause);
    }

    public DocumentAccessException(Throwable cause) {
        super(cause);
    }
}