@@ -2606,11 +2606,10 @@ public void downloadTranslationMemoryExport(TranslationMemoryJob job, OutputStre
26062606 * @return {@link TranslationMemoryJob} object for the completed import; its result carries the ID
26072607 * of the new translation memory.
26082608 * @throws IllegalArgumentException If the input file does not exist.
2609- * @throws IOException Not thrown; local I/O failures are reported as {@link DeepLException}.
2610- * Declared for source compatibility.
2609+ * @throws IOException If the input file cannot be read.
26112610 * @throws InterruptedException If the thread is interrupted during execution of this function.
2612- * @throws DeepLException If the input file cannot be read (with the I/O error as cause), the
2613- * import fails, or any error occurs while communicating with the DeepL API.
2611+ * @throws DeepLException If the import fails, or any error occurs while communicating with the
2612+ * DeepL API.
26142613 */
26152614 public TranslationMemoryJob importTranslationMemoryFromFilepath (
26162615 File inputFile , @ Nullable String displayName )
@@ -2631,12 +2630,10 @@ public TranslationMemoryJob importTranslationMemoryFromFilepath(
26312630 * @return {@link TranslationMemoryJob} object for the completed import; its result carries the ID
26322631 * of the new translation memory.
26332632 * @throws IllegalArgumentException If the input file does not exist.
2634- * @throws IOException Not thrown; local I/O failures are reported as {@link DeepLException}.
2635- * Declared for source compatibility.
2633+ * @throws IOException If the input file cannot be read.
26362634 * @throws InterruptedException If the thread is interrupted during execution of this function.
2637- * @throws DeepLException If the input file cannot be read (with the I/O error as cause), the
2638- * timeout is exceeded, the import fails, or any error occurs while communicating with the
2639- * DeepL API.
2635+ * @throws DeepLException If the timeout is exceeded, the import fails, or any error occurs while
2636+ * communicating with the DeepL API.
26402637 * @see DeepLClient#importTranslationMemoryFromFilepath(File, String)
26412638 */
26422639 public TranslationMemoryJob importTranslationMemoryFromFilepath (
@@ -2659,12 +2656,10 @@ public TranslationMemoryJob importTranslationMemoryFromFilepath(
26592656 * @return {@link TranslationMemoryJob} object for the completed import; its result carries the ID
26602657 * of the new translation memory.
26612658 * @throws IllegalArgumentException If the input file does not exist.
2662- * @throws IOException Not thrown; local I/O failures are reported as {@link DeepLException}.
2663- * Declared for source compatibility.
2659+ * @throws IOException If the input file cannot be read.
26642660 * @throws InterruptedException If the thread is interrupted during execution of this function.
2665- * @throws DeepLException If the input file cannot be read (with the I/O error as cause), the
2666- * timeout is exceeded, the import fails, or any error occurs while communicating with the
2667- * DeepL API.
2661+ * @throws DeepLException If the timeout is exceeded, the import fails, or any error occurs while
2662+ * communicating with the DeepL API.
26682663 */
26692664 public TranslationMemoryJob importTranslationMemoryFromFilepath (
26702665 File inputFile , @ Nullable ImportTranslationMemoryOptions options )
@@ -2737,12 +2732,11 @@ public TranslationMemoryJob importTranslationMemoryFromFilepath(File inputFile)
27372732 * @param translationMemoryId ID of the translation memory to export.
27382733 * @param outputFile File to write the exported translation memory to.
27392734 * @return {@link TranslationMemoryJob} object for the completed export.
2740- * @throws IOException Not thrown; local I/O failures are reported as {@link DeepLException}.
2741- * Declared for source compatibility .
2735+ * @throws IOException If the output path is occupied or its directory does not exist (checked
2736+ * before the export job is created), or writing the file fails .
27422737 * @throws InterruptedException If the thread is interrupted during execution of this function.
2743- * @throws DeepLException If the output path is occupied or its directory does not exist (checked
2744- * before the export job is created), writing the file fails (with the I/O error as cause),
2745- * the export fails, or any error occurs while communicating with the DeepL API.
2738+ * @throws DeepLException If the export fails, or any error occurs while communicating with the
2739+ * DeepL API.
27462740 */
27472741 public TranslationMemoryJob exportTranslationMemoryToFilepath (
27482742 String translationMemoryId , File outputFile )
@@ -2760,13 +2754,11 @@ public TranslationMemoryJob exportTranslationMemoryToFilepath(
27602754 * indefinitely. The job status is polled every 5 seconds; the last wait is cut short at the
27612755 * timeout.
27622756 * @return {@link TranslationMemoryJob} object for the completed export.
2763- * @throws IOException Not thrown; local I/O failures are reported as {@link DeepLException}.
2764- * Declared for source compatibility .
2757+ * @throws IOException If the output path is occupied or its directory does not exist (checked
2758+ * before the export job is created), or writing the file fails .
27652759 * @throws InterruptedException If the thread is interrupted during execution of this function.
2766- * @throws DeepLException If the output path is occupied or its directory does not exist (checked
2767- * before the export job is created), writing the file fails (with the I/O error as cause),
2768- * the timeout is exceeded, the export fails, or any error occurs while communicating with the
2769- * DeepL API.
2760+ * @throws DeepLException If the timeout is exceeded, the export fails, or any error occurs while
2761+ * communicating with the DeepL API.
27702762 * @see DeepLClient#exportTranslationMemoryToFilepath(String, File)
27712763 */
27722764 public TranslationMemoryJob exportTranslationMemoryToFilepath (
@@ -2777,11 +2769,7 @@ public TranslationMemoryJob exportTranslationMemoryToFilepath(
27772769 createTranslationMemoryExport (translationMemoryId );
27782770 TranslationMemoryJob job =
27792771 waitUntilTranslationMemoryJobDone (translationMemoryExport .getJobId (), timeout );
2780- try {
2781- downloadTranslationMemoryExport (job , outputFile );
2782- } catch (IOException exception ) {
2783- throw wrapLocalIOException ("Failed to write translation memory export" , exception );
2784- }
2772+ downloadTranslationMemoryExport (job , outputFile );
27852773 return job ;
27862774 }
27872775
@@ -2831,11 +2819,7 @@ public TranslationMemoryJob exportTranslationMemoryToFilepath(
28312819 createTranslationMemoryExport (translationMemoryId );
28322820 TranslationMemoryJob job =
28332821 waitUntilTranslationMemoryJobDone (translationMemoryExport .getJobId (), timeout );
2834- try {
2835- downloadTranslationMemoryExport (job , outputStream );
2836- } catch (IOException exception ) {
2837- throw wrapLocalIOException ("Failed to write translation memory export" , exception );
2838- }
2822+ downloadTranslationMemoryExport (job , outputStream );
28392823 return job ;
28402824 }
28412825
@@ -2922,48 +2906,25 @@ private static String translationMemoryJobId(TranslationMemoryJob job)
29222906 /**
29232907 * Reads a TMX file for import; a missing file is an argument error, raised before any request.
29242908 */
2925- private static byte [] readTranslationMemoryFile (@ Nullable File inputFile )
2926- throws DeepLException , InterruptedException {
2909+ private static byte [] readTranslationMemoryFile (@ Nullable File inputFile ) throws IOException {
29272910 if (inputFile == null || !inputFile .exists ()) {
29282911 throw new IllegalArgumentException ("inputFile must be an existing file" );
29292912 }
2930- try {
2931- return Files .readAllBytes (inputFile .toPath ());
2932- } catch (IOException exception ) {
2933- throw wrapLocalIOException ("Failed to read translation memory file" , exception );
2934- }
2913+ return Files .readAllBytes (inputFile .toPath ());
29352914 }
29362915
29372916 /** Checks the output file of an export so a bad path fails before the export job is created. */
2938- private static void checkExportOutputFile (@ Nullable File outputFile ) throws DeepLException {
2917+ private static void checkExportOutputFile (@ Nullable File outputFile ) throws IOException {
29392918 if (outputFile == null ) {
29402919 throw new IllegalArgumentException ("outputFile must not be null" );
29412920 }
29422921 if (outputFile .exists ()) {
2943- throw new DeepLException ("File already exists at output path" );
2922+ throw new IOException ("File already exists at output path" );
29442923 }
29452924 File directory = outputFile .getAbsoluteFile ().getParentFile ();
29462925 if (directory == null || !directory .isDirectory ()) {
2947- throw new DeepLException ("Directory of output path does not exist" );
2948- }
2949- }
2950-
2951- /**
2952- * Wraps a local I/O failure in a {@link DeepLException}; an interrupted I/O operation is reported
2953- * as {@link InterruptedException} instead, as caller cancellation is never wrapped.
2954- */
2955- private static DeepLException wrapLocalIOException (String message , IOException exception )
2956- throws InterruptedException {
2957- boolean interrupted =
2958- exception instanceof java .nio .channels .ClosedByInterruptException
2959- || (exception instanceof InterruptedIOException
2960- && !(exception instanceof java .net .SocketTimeoutException ));
2961- if (interrupted ) {
2962- InterruptedException interruptedException = new InterruptedException (exception .getMessage ());
2963- interruptedException .initCause (exception );
2964- throw interruptedException ;
2926+ throw new FileNotFoundException ("Directory of output path does not exist" );
29652927 }
2966- return new DeepLException (message + ": " + exception .getMessage (), exception );
29672928 }
29682929
29692930 /** Extracts the ID of the given Spoken Terms collection. */
0 commit comments