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

com.relogiclabs.json.schema.exception.CommonException Maven / Gradle / Ivy

Go to download

The New JSON Schema prioritizes simplicity, conciseness, and readability, making it user-friendly and accessible without the need for extensive prior knowledge. It offers efficient read-write facilities, precise JSON document definition through various data types and functions, and extensibility to meet modern web service diverse requirements.

There is a newer version: 1.12.1
Show newest version
package com.relogiclabs.json.schema.exception;

import com.relogiclabs.json.schema.message.ErrorDetail;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

public class CommonException extends RuntimeException {
    @Getter private final String code;
    private Map attributes;

    public CommonException(String code, String message, Throwable cause) {
        super(message, cause);
        this.code = code;
    }

    public CommonException(String code, String message) {
        this(code, message, null);
    }

    public CommonException(ErrorDetail detail, Throwable cause) {
        this(detail.getCode(), detail.getMessage(), cause);
    }

    public CommonException(ErrorDetail detail) {
        this(detail, null);
    }

    public String getAttribute(String name) {
        if(attributes == null) return null;
        return attributes.get(name);
    }

    public void setAttribute(String name, String value) {
        if(attributes == null) attributes = new HashMap<>(5);
        attributes.put(name, value);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy