Skip to content

Commit 06b881e

Browse files
Improve exception handling when getting enum constants (vojtechhabarta#677)
1 parent 4a349ce commit 06b881e

File tree

1 file changed

+2
-1
lines changed
  • typescript-generator-core/src/main/java/cz/habarta/typescript/generator/parser

1 file changed

+2
-1
lines changed

typescript-generator-core/src/main/java/cz/habarta/typescript/generator/parser/Jackson2Parser.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,12 +719,13 @@ private DeclarationModel parseEnumOrObjectEnum(SourceType<Class<?>> sourceClass,
719719

720720
final List<EnumMemberModel> enumMembers = new ArrayList<>();
721721
if (sourceClass.type.isEnum()) {
722+
@SuppressWarnings("unchecked")
722723
final Class<Enum> enumClass = (Class<Enum>) sourceClass.type;
723724
final List<Field> constants = Arrays.stream(enumClass.getEnumConstants()).map(e -> {
724725
try {
725726
return enumClass.getDeclaredField(e.name());
726727
} catch (NoSuchFieldException noSuchFieldException) {
727-
return null;
728+
throw new RuntimeException(noSuchFieldException);
728729
}
729730
}).collect(Collectors.toList());
730731
for (Field constant : constants) {

0 commit comments

Comments
 (0)