Skip to content

Commit

Permalink
feat(impl):[#567] fix message when wrong direction
Browse files Browse the repository at this point in the history
  • Loading branch information
ds-ext-kmassalski committed May 1, 2024
1 parent e3767c4 commit ca406f0
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
********************************************************************************/
package org.eclipse.tractusx.irs.component.enums;

import java.util.NoSuchElementException;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import com.fasterxml.jackson.annotation.JsonCreator;
Expand Down Expand Up @@ -62,7 +64,12 @@ public static Direction fromValue(final String value) {
return Stream.of(Direction.values())
.filter(direction -> direction.name.equals(value))
.findFirst()
.orElseThrow();
.orElseThrow(() -> new NoSuchElementException("Unsupported Direction: " + value
+ ". Must be one of: " + supportedDirections()));
}

private static String supportedDirections() {
return Stream.of(Direction.values()).map(direction -> direction.name).collect(Collectors.joining(", "));
}

/**
Expand Down

0 comments on commit ca406f0

Please sign in to comment.