summaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com/yahoo/search/yql/ProgramCompileException.java
blob: 46dfb780e2df48e8dd40808cc9ea5cb987846f3f (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
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.yql;

class ProgramCompileException extends RuntimeException {

    private Location sourceLocation;

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

    public ProgramCompileException(String message, Object... args) {
        super(formatMessage(message, args));
    }

    private static String formatMessage(String message, Object... args) {
        return args == null ? message : String.format(message, args);
    }

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

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

    public ProgramCompileException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
        super(message, cause, enableSuppression, writableStackTrace);
    }


    public ProgramCompileException(Location sourceLocation, String message, Object... args) {
        super(String.format("%s %s", sourceLocation != null ? sourceLocation : "", args == null ? message : String.format(message, args)));
        this.sourceLocation = sourceLocation;
    }

}