Skip to content

Commit

Permalink
Trap errors in voice map init loop so we can continue processing
Browse files Browse the repository at this point in the history
  • Loading branch information
docwho2 committed Dec 19, 2023
1 parent 1073a31 commit 5dd99d5
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,12 @@ protected AbstractFlow() {
List<LocaleVoiceId> list = mapper.readerForListOf(LocaleVoiceId.class).readValue(vmapStr);
for (var map : list) {
if (map.locale != null && map.voiceId != null) {
log.debug("Adding Locale [" + map.locale + "] with VoiceId [" + map.voiceId + "]");
voice_map.put(Locale.forLanguageTag(map.locale), ResponseSpeak.VoiceId.valueOf(map.voiceId));
try {
log.debug("Adding Locale [" + map.locale + "] with VoiceId [" + map.voiceId + "]");
voice_map.put(Locale.forLanguageTag(map.locale), ResponseSpeak.VoiceId.valueOf(map.voiceId));
} catch (Exception e) {
log.error("Error processing Locale", e);
}
}
}
} catch (Exception e) {
Expand Down Expand Up @@ -240,12 +244,12 @@ public final SMAResponse handleRequest(SMARequest event, Context cntxt) {
// And set as current
final var dr_nra = action.getNextRoutingAction();
final var dr_List = getActions(dr_nra, event);
if ( !action.getId().toString().equals(dr_actionIdStr) ) {
if (!action.getId().toString().equals(dr_actionIdStr)) {
// We weren't the current action ID, so reset to that
final var attrs_new = dr_List.getLast().getTransactionAttributes();
attrs_new.put(CURRENT_ACTION_ID, dr_actionIdStr);
res = SMAResponse.builder().withTransactionAttributes(attrs_new)
.withActions(dr_List.stream().map(a -> a.getResponse()).collect(Collectors.toList())).build();
.withActions(dr_List.stream().map(a -> a.getResponse()).collect(Collectors.toList())).build();
} else {
res = defaultResponse(action, event);
}
Expand Down

0 comments on commit 5dd99d5

Please sign in to comment.