Ignore:
Timestamp:
2021-08-03T17:12:35+12:00 (3 years ago)
Author:
davidb
Message:

Improve error handling for calls to the Reo Tuhituhi API

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gs3-extensions/atea-nlp-tools/trunk/src/koreromaori-proxy/src/main/java/org/atea/nlptools/koreromaoriinterface/TranscriptionServlet.java

    r35241 r35242  
    2323import org.apache.logging.log4j.LogManager;
    2424import org.apache.logging.log4j.Logger;
     25import org.atea.nlptools.koreromaoriinterface.exceptions.ReoTuhituhiException;
    2526import org.atea.nlptools.koreromaoriinterface.models.AudioFilePart;
    2627import org.atea.nlptools.koreromaoriinterface.models.MyTranscriptionResponse;
     
    8788        String[] audioFileKeys = audioFileKeysParameter.split("\\|");
    8889
     90        // Create our own representation of each part
    8991        ArrayList<AudioFilePart> audioFileParts = new ArrayList<AudioFilePart>(audioFileKeys.length);
    9092        for (String audioFileKey : audioFileKeys)
     
    9597        }
    9698
    97         try
     99        try 
    98100        {
    99             List<AudioFilePart> results = transcriptionService.GetTranscriptions(audioFileParts);
     101            List<AudioFilePart> results = transcriptionService.getTranscriptions(audioFileParts);
     102
    100103            List<MyTranscriptionResponse> responses = new ArrayList<MyTranscriptionResponse>(results.size());
    101 
    102104            for (AudioFilePart result : results) {
    103105                responses.add(MyTranscriptionResponse.FromTranscriptionResult(result.getTranscriptionResult(), result.fileName));
     
    107109            writer.append(json);
    108110        }
     111        catch (ReoTuhituhiException rtex)
     112        {
     113            response.sendError(502, "Call to the Reo Tuhituhi API failed.");
     114        }
    109115        catch (Exception ex)
    110116        {
    111             response.sendError(500, "Call to the Reo Tuhituhi API failed." + ex);
     117            response.sendError(500, "Failed to process the request.");
    112118            logger.error("Failed to complete API call", ex);
    113119        }
Note: See TracChangeset for help on using the changeset viewer.