Skip to content

Commit 4d2e71b

Browse files
authored
Fix error message after loading string this occurs when there an riot exception (#44)
1 parent dd9f512 commit 4d2e71b

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/main/java/org/eclipse/esmf/ame/resolver/strategy/ResolutionStrategy.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public abstract class ResolutionStrategy extends AbstractResolutionStrategy {
5252
public final Path processingRootPath;
5353
public final Model aspectModel;
5454

55-
public ResolutionStrategy( final String aspectModel, final Path processingRootPath ) throws RiotException {
55+
public ResolutionStrategy( final String aspectModel, final Path processingRootPath ) {
5656
this.processingRootPath = processingRootPath;
5757
this.aspectModel = loadTurtleFromString( aspectModel );
5858
}
@@ -95,8 +95,15 @@ private Try<Model> tryOnFailure( final AspectModelUrn aspectModelUrn ) {
9595
protected Model loadTurtleFromString( final String aspectModel ) {
9696
try ( ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
9797
aspectModel.getBytes( StandardCharsets.UTF_8 ) ) ) {
98-
return TurtleLoader.loadTurtle( byteArrayInputStream ).getOrElseThrow(
99-
error -> new RiotException( error.getCause().getMessage(), error.getCause() ) );
98+
Try<Model> resultTry = TurtleLoader.loadTurtle( byteArrayInputStream );
99+
100+
if ( resultTry.isFailure() ) {
101+
Throwable cause = resultTry.getCause();
102+
String errorMessage = cause != null ? cause.getMessage() : "Unknown Error";
103+
throw new RiotException( errorMessage, cause );
104+
}
105+
106+
return resultTry.get();
100107
} catch ( IOException e ) {
101108
LOG.error( "Cannot read file." );
102109
throw new FileReadException( "Error reading the Aspect Model file.", e );

0 commit comments

Comments
 (0)