aboutsummaryrefslogtreecommitdiffstats
path: root/vespa-athenz/src/main/java/com/yahoo/vespa/athenz/client/zts/ZtsClientException.java
blob: 3b2dd435e54ba87e077d8d8c3f745a3d9ff0ab0b (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.athenz.client.zts;

/**
 * An exception that can be thrown by {@link ZtsClient} implementations.
 *
 * @author bjorncs
 */
public class ZtsClientException extends RuntimeException {

    private final int errorCode;
    private final String description;

    public ZtsClientException(int errorCode, String description) {
        super(createMessage(errorCode, description));
        this.errorCode = errorCode;
        this.description = description;
    }

    public int getErrorCode() {
        return errorCode;
    }

    public String getDescription() {
        return description;
    }

    private static String createMessage(int code, String description) {
        return String.format("Received error from ZTS: code=%d, message=\"%s\"", code, description);
    }

}