aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/matchers/psystem/queries/PProblem.java
blob: 1fe4f541991f315f397996b033440736e7d8e850 (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*******************************************************************************
 * Copyright (c) 2010-2014, Bergmann Gabor, Istvan Rath and Daniel Varro
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v. 2.0 which is available at
 * http://www.eclipse.org/legal/epl-v20.html.
 * 
 * SPDX-License-Identifier: EPL-2.0
 *******************************************************************************/
package tools.refinery.viatra.runtime.matchers.psystem.queries;

import tools.refinery.viatra.runtime.matchers.planning.QueryProcessingException;

/**
 * Represents an error that was detected while the {@link PQuery} object was built from a source.
 * @author Bergmann Gabor
 *
 */
public class PProblem {

    private final String shortMessage;
    private final String location; 
    private final Exception exception;

    public PProblem(String shortMessage) {
        this(null, shortMessage, null, null);
    }
    /**
     * @since 2.0
     */
    public PProblem(String shortMessage, Integer line, Integer column) {
        this(null, shortMessage, line, column);
    }
    public PProblem(QueryProcessingException exception) {
        this(exception, exception.getShortMessage(), null, null);
    }
    public PProblem(Exception exception, String shortMessage) {
        this(exception, shortMessage, null, null);
    }
    
    /**
     * @since 2.0
     */
    public PProblem(Exception exception, String shortMessage, Integer line, Integer column) {
        this.shortMessage = shortMessage;
        this.exception = exception;
        if (line == null) {
            location = "Unspecified location";
        } else if (column == null) {
            location = String.format("Line %d", line);
        } else {
            location = String.format("Line %d Column %d", line, column);
        }
    }

    public String getShortMessage() {
        return shortMessage;
    }
    public Exception getException() {
        return exception;
    }
    /**
     * @since 2.0
     */
    public String getLocation() {
        return location;
    }
    
}