Skip to content

Commit bfa502e

Browse files
authored
Feature/default volume (#19)
1 parent 27101fd commit bfa502e

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/main/java/de/unistuttgart/memorybackend/service/ConfigService.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,17 @@ public Configuration getAllConfigurations(final UUID id, final String accessToke
8080
final String userId = jwtValidatorService.extractUserId(accessToken);
8181

8282
KeybindingDTO keyBindingVolumeLevel = overworldClient.getKeybindingStatistic(userId, "VOLUME_LEVEL", accessToken);
83-
Integer volumeLevel = Integer.parseInt(keyBindingVolumeLevel.getKey());
83+
Integer volumeLevel;
84+
if (keyBindingVolumeLevel.getKey() == null || keyBindingVolumeLevel.getKey().isEmpty()) {
85+
volumeLevel = 0;
86+
}
87+
else {
88+
try {
89+
volumeLevel = Integer.parseInt(keyBindingVolumeLevel.getKey());
90+
} catch (NumberFormatException e) {
91+
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "Invalid volume level format.");
92+
}
93+
}
8494

8595
Configuration config = configurationRepository
8696
.findById(id)

0 commit comments

Comments
 (0)