summaryrefslogtreecommitdiffstats
path: root/clustercontroller-utils/src/main/java/com/yahoo/vespa/clustercontroller/utils/staterestapi/errors/MissingUnitException.java
blob: c45ce2527cbfd536a5e967aa0bf067d4ffc2d6c2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.utils.staterestapi.errors;

public class MissingUnitException extends StateRestApiException {

    private static String createMessage(String[] path, int level) {
        StringBuilder sb = new StringBuilder();
        sb.append("No such resource '");
        for (int i=0; i<=level; ++i) {
            if (i != 0) sb.append('/');
            sb.append(path[i]);
        }
        return sb.append("'.").toString();
    }

    public MissingUnitException(String[] path, int level) {
        super(createMessage(path, level));
        setHtmlCode(404);
        setHtmlStatus(getMessage());
    }

}