All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.blade.kit.json.ParseException Maven / Gradle / Ivy

package com.blade.kit.json;

public class ParseException extends RuntimeException {

    private int position = 0;
    private String json = "";

    public ParseException(String json, int position, String message) {
        super(message);
        this.json = json;
        this.position = position;
    }

    @Override
    public String getMessage() {
        final int maxTipLength = 10;
        int end = position + 1;
        int start = end - maxTipLength;
        if (start < 0) start = 0;
        if (end > json.length()) end = json.length();
        return String.format("%s  (%d):%s", json.substring(start, end), position, super.getMessage());
    }

    public String getJson() {
        return this.json;
    }

    public int getPosition() {
        return this.position;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy