aboutsummaryrefslogtreecommitdiffstats
path: root/main/exception/ExceptionManager.java
blob: 0ceb25b44fb03bc134e73f6d8fd182e699df251f (plain)
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
package com.jantuomi.interpreter.main.exception;

import java.util.List;

/**
 * Created by jan on 10.6.2016.
 */
public class ExceptionManager {

    private static final ExceptionManager instance = new ExceptionManager();

    private ExceptionManager() {
    }

    public static ExceptionManager getInstance() {
        return instance;
    }

    public static void raise(InterpreterException.Exception ex, int line, List<String> args) {
        InterpreterException e = new InterpreterException(ex);
        String output = e.what();
        for (String arg : args) {
            output = String.format(output, arg);
        }
        System.err.println(String.format("[%s] line: %d %s", ex.toString(), line, output));
    }


}