Skip to content
JobException.java 1.08 KiB
Newer Older
/*
 * This file is part of vospace-file-service
 * Copyright (C) 2021 Istituto Nazionale di Astrofisica
 * SPDX-License-Identifier: GPL-3.0-or-later
 */
package it.inaf.ia2.transfer.exception;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;

@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public class JobException extends RuntimeException {

    public static enum Type {

        TRANSIENT("transient"),
        FATAL("fatal");

        private final String value;

        private Type(String v) {
            value = v;
        }

        public String value() {
            return value;
        }
    }

    private final Type type;
    private String errorDetail;

    public JobException(Type type, String message) {
        super(message);
        this.type = type;
    }

    public Type getType() {
        return type;
    }

    public String getErrorDetail() {
        return errorDetail;
    }

    public final JobException setErrorDetail(String errorDetail) {
        this.errorDetail = errorDetail;
        return this;
    }
}