com.farao_community.farao.gridcapa_swe_commons.exception.AbstractSweException Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gridcapa-swe-commons Show documentation
Show all versions of gridcapa-swe-commons Show documentation
Common lib to gridcapa swe process
The newest version!
/*
* Copyright (c) 2021, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package com.farao_community.farao.gridcapa_swe_commons.exception;
/**
* Custom abstract exception to be extended by all application exceptions.
* Any subclass may be automatically wrapped to a JSON API error message if needed
*
* @author Theo Pascoli {@literal }
*/
public abstract class AbstractSweException extends RuntimeException {
protected AbstractSweException(String message) {
super(message);
}
protected AbstractSweException(String message, Throwable throwable) {
super(message, throwable);
}
public abstract int getStatus();
public abstract String getCode();
public final String getTitle() {
return getMessage();
}
public final String getDetails() {
String message = getMessage();
if (message != null) {
StringBuilder sb = new StringBuilder(message);
Throwable cause = getCause();
while (cause != null) {
sb.append("; nested exception is ").append(cause);
cause = cause.getCause();
if (cause instanceof SweInvalidDataNoDetailsException) {
return cause.getMessage();
}
}
return sb.toString();
} else {
return "No details";
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy