Skip to content
Snippets Groups Projects
Commit 6959c91c authored by Irina Muntean's avatar Irina Muntean
Browse files

New exception type containing multiple ChainTransformation exceptions

Issue-Ref: 4168
Issue-Url: af3#4168



Signed-off-by: default avatarIrina Muntean <muntean@fortiss.org>
parent fb401dbc
No related branches found
No related tags found
1 merge request!159Add caught exception to list and throw new exception
/*-------------------------------------------------------------------------+
| Copyright 2021 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.extension.exception;
import java.util.List;
/**
*
* @author muntean
*/
public class AllChainTransformationsFailedException extends ChainTransformationFailedException {
/** Stores a reference to the transformation provider chain. */
private final List<ChainTransformationFailedException> exceptionList;
/** Constructor. */
public AllChainTransformationsFailedException(
List<ChainTransformationFailedException> exceptionList) {
super(null, null, null, null);
this.exceptionList = exceptionList;
}
/** {@inheritDoc} */
@Override
public String getMessage() {
return getMessage(0);
}
/**
* @param i
* @return
*/
private String getMessage(int counter) {
String msg = "";
for(TransformationFailedException ctfe : this.exceptionList) {
String tabs = addTabs(counter);
msg += tabs + "Failed Provider:\n";
msg += tabs + ctfe.getFailedProvider().getClass().getSimpleName() + "\n";
TransformationFailedException cause = (TransformationFailedException)ctfe.getCause();
if(cause != null) {
msg += tabs + "Cause:\n";
if(cause instanceof AllChainTransformationsFailedException)
msg += tabs + ((AllChainTransformationsFailedException)cause)
.getMessage(counter + 1) + "\n";
else
msg += tabs + cause.getMessage() + "\n";
}
}
return msg;
}
/** Returns @counter tabs in a string. */
private String addTabs(int counter) {
String msg = "";
for(int i = 0; i < counter; i++) {
msg += "\t";
}
return msg;
}
/** Returns exceptionList. */
public List<ChainTransformationFailedException> getExceptionList() {
return exceptionList;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment