From 029c038a49f5b1146b0bfd79d802335207e02eb1 Mon Sep 17 00:00:00 2001 From: CalDescent Date: Wed, 18 Aug 2021 16:23:46 +0100 Subject: [PATCH] Catch runtime exceptions (e.g. IllegalStateException) when using the arbitrary data reader/writer. --- src/main/java/org/qortal/api/resource/ArbitraryResource.java | 2 +- src/main/java/org/qortal/api/resource/WebsiteResource.java | 4 ++-- .../controller/arbitrary/ArbitraryDataBuildManager.java | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/qortal/api/resource/ArbitraryResource.java b/src/main/java/org/qortal/api/resource/ArbitraryResource.java index 233780fb..1e934b09 100644 --- a/src/main/java/org/qortal/api/resource/ArbitraryResource.java +++ b/src/main/java/org/qortal/api/resource/ArbitraryResource.java @@ -278,7 +278,7 @@ public class ArbitraryResource { } catch (IOException | DataException e) { LOGGER.info("Unable to create arbitrary data file: {}", e.getMessage()); throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.REPOSITORY_ISSUE); - } catch (IllegalStateException e) { + } catch (RuntimeException e) { LOGGER.info("Unable to create arbitrary data file: {}", e.getMessage()); throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.INVALID_DATA); } diff --git a/src/main/java/org/qortal/api/resource/WebsiteResource.java b/src/main/java/org/qortal/api/resource/WebsiteResource.java index 87d439c5..43ba30c7 100644 --- a/src/main/java/org/qortal/api/resource/WebsiteResource.java +++ b/src/main/java/org/qortal/api/resource/WebsiteResource.java @@ -112,7 +112,7 @@ public class WebsiteResource { } catch (IOException | DataException e) { LOGGER.info("Unable to create arbitrary data file: {}", e.getMessage()); throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.REPOSITORY_ISSUE); - } catch (IllegalStateException e) { + } catch (RuntimeException e) { LOGGER.info("Unable to create arbitrary data file: {}", e.getMessage()); throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.INVALID_DATA); } @@ -214,7 +214,7 @@ public class WebsiteResource { } catch (IOException | DataException e) { LOGGER.info("Unable to create arbitrary data file: {}", e.getMessage()); throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.REPOSITORY_ISSUE); - } catch (IllegalStateException e) { + } catch (RuntimeException e) { LOGGER.info("Unable to create arbitrary data file: {}", e.getMessage()); throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.INVALID_DATA); } diff --git a/src/main/java/org/qortal/controller/arbitrary/ArbitraryDataBuildManager.java b/src/main/java/org/qortal/controller/arbitrary/ArbitraryDataBuildManager.java index 52eaf5b5..63c33a7b 100644 --- a/src/main/java/org/qortal/controller/arbitrary/ArbitraryDataBuildManager.java +++ b/src/main/java/org/qortal/controller/arbitrary/ArbitraryDataBuildManager.java @@ -69,7 +69,7 @@ public class ArbitraryDataBuildManager implements Runnable { this.removeFromQueue(resourceId); LOGGER.info("Finished building {}", queueItem); - } catch (IOException | DataException e) { + } catch (IOException | DataException | RuntimeException e) { LOGGER.info("Error building {}: {}", queueItem, e.getMessage()); // Something went wrong - so remove it from the queue, and add to failed builds list queueItem.setFailed(true);