This is an automated email from the ASF dual-hosted git repository.
desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git
The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
new efc8fd2 Better error messages.
efc8fd2 is described below
commit efc8fd2bee8349dffce6564fea3a56ed305fbb49
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Thu Feb 11 11:25:35 2021 +0100
Better error messages.
---
.../org/apache/sis/internal/processing/image/Isolines.java | 12 +++++++++---
.../test/java/org/apache/sis/image/ImageProcessorTest.java | 2 ++
.../java/org/apache/sis/test/suite/FeatureTestSuite.java | 2 +-
.../src/main/java/org/apache/sis/util/resources/Errors.java | 10 ++++++++++
.../java/org/apache/sis/util/resources/Errors.properties | 2 ++
.../java/org/apache/sis/util/resources/Errors_fr.properties | 2 ++
6 files changed, 26 insertions(+), 4 deletions(-)
diff --git
a/core/sis-feature/src/main/java/org/apache/sis/internal/processing/image/Isolines.java
b/core/sis-feature/src/main/java/org/apache/sis/internal/processing/image/Isolines.java
index a99062e..7ef3482 100644
---
a/core/sis-feature/src/main/java/org/apache/sis/internal/processing/image/Isolines.java
+++
b/core/sis-feature/src/main/java/org/apache/sis/internal/processing/image/Isolines.java
@@ -33,6 +33,7 @@ import org.opengis.referencing.operation.TransformException;
import org.apache.sis.image.PixelIterator;
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.util.ArraysExt;
+import org.apache.sis.util.resources.Errors;
import static
org.apache.sis.internal.processing.image.IsolineTracer.UPPER_LEFT;
import static
org.apache.sis.internal.processing.image.IsolineTracer.UPPER_RIGHT;
@@ -471,17 +472,17 @@ abort: while (iterator.next()) {
private NavigableMap<Double,Shape>[] isolines() {
if (isolines == null) {
if (task == null) {
- throw new CompletionException(null);
+ throw new
CompletionException(Errors.format(Errors.Keys.BackgroundComputationFailed),
null);
}
try {
isolines = Isolines.toArray(task.get());
task = null;
} catch (InterruptedException e) {
// Do not clear `task`: the result may become available
later.
- throw new CompletionException(e);
+ throw new
CompletionException(Errors.format(Errors.Keys.InterruptedWhileWaitingResult),
e);
} catch (ExecutionException e) {
task = null;
- throw new CompletionException(e.getCause());
+ throw new
CompletionException(Errors.format(Errors.Keys.BackgroundComputationFailed),
e.getCause());
}
}
return isolines;
@@ -496,5 +497,10 @@ abort: while (iterator.next()) {
@Override public NavigableMap<Double,Shape> get(final int band) {
return isolines()[band];
}
+
+ /** Returns the list content as an array. */
+ @Override public Object[] toArray() {
+ return isolines().clone();
+ }
}
}
diff --git
a/core/sis-feature/src/test/java/org/apache/sis/image/ImageProcessorTest.java
b/core/sis-feature/src/test/java/org/apache/sis/image/ImageProcessorTest.java
index 8158953..22dd7ae 100644
---
a/core/sis-feature/src/test/java/org/apache/sis/image/ImageProcessorTest.java
+++
b/core/sis-feature/src/test/java/org/apache/sis/image/ImageProcessorTest.java
@@ -21,6 +21,7 @@ import java.awt.Shape;
import java.awt.image.BufferedImage;
import java.awt.image.RenderedImage;
import org.apache.sis.internal.processing.image.IsolinesTest;
+import org.apache.sis.test.DependsOn;
import org.opengis.referencing.operation.MathTransform;
import org.apache.sis.test.TestCase;
import org.junit.Test;
@@ -37,6 +38,7 @@ import static org.apache.sis.test.TestUtilities.getSingleton;
* @since 1.1
* @module
*/
+@DependsOn(org.apache.sis.internal.processing.image.IsolinesTest.class)
public final strictfp class ImageProcessorTest extends TestCase {
/**
* Tests {@link ImageProcessor#isolines(RenderedImage, double[][],
MathTransform)}.
diff --git
a/core/sis-feature/src/test/java/org/apache/sis/test/suite/FeatureTestSuite.java
b/core/sis-feature/src/test/java/org/apache/sis/test/suite/FeatureTestSuite.java
index 20a2f4f..3a7d3ee 100644
---
a/core/sis-feature/src/test/java/org/apache/sis/test/suite/FeatureTestSuite.java
+++
b/core/sis-feature/src/test/java/org/apache/sis/test/suite/FeatureTestSuite.java
@@ -80,6 +80,7 @@ import org.junit.runners.Suite;
org.apache.sis.internal.coverage.j2d.ImageLayoutTest.class,
org.apache.sis.internal.coverage.j2d.ScaledColorSpaceTest.class,
org.apache.sis.internal.coverage.j2d.ColorizerTest.class,
+ org.apache.sis.internal.processing.image.IsolinesTest.class,
org.apache.sis.image.DataTypeTest.class,
org.apache.sis.image.PlanarImageTest.class,
org.apache.sis.image.ComputedImageTest.class,
@@ -112,7 +113,6 @@ import org.junit.runners.Suite;
org.apache.sis.coverage.grid.ResampledGridCoverageTest.class,
// Index and processing
- org.apache.sis.internal.processing.image.IsolinesTest.class,
org.apache.sis.index.tree.PointTreeNodeTest.class,
org.apache.sis.index.tree.PointTreeTest.class
})
diff --git
a/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
b/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
index ff395a8..b35f0e9 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
@@ -73,6 +73,11 @@ public final class Errors extends IndexedResourceBundle {
public static final short AmbiguousName_3 = 1;
/**
+ * Computation in background failed.
+ */
+ public static final short BackgroundComputationFailed = 191;
+
+ /**
* This object can iterate only once.
*/
public static final short CanIterateOnlyOnce = 172;
@@ -492,6 +497,11 @@ public final class Errors extends IndexedResourceBundle {
public static final short IntegerOverflow_1 = 10;
/**
+ * Interrupted while waiting result.
+ */
+ public static final short InterruptedWhileWaitingResult = 192;
+
+ /**
* “{0}” is an invalid version identifier.
*/
public static final short InvalidVersionIdentifier_1 = 179;
diff --git
a/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
b/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
index a48e955..0e72218 100644
---
a/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
+++
b/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
@@ -26,6 +26,7 @@
#
AlreadyInitialized_1 = \u2018{0}\u2019 is already initialized.
AmbiguousName_3 = Name \u201c{2}\u201d is ambiguous because
it can be understood as either \u201c{0}\u201d or \u201c{1}\u201d.
+BackgroundComputationFailed = Computation in background failed.
CanIterateOnlyOnce = This object can iterate only once.
CanNotAddToExclusiveSet_2 = No element can be added to this set
because properties \u2018{0}\u2019 and \u2018{1}\u2019 are mutually exclusive.
CanNotAssign_2 = Can not assign \u201c{1}\u201d to
\u201c{0}\u201d.
@@ -109,6 +110,7 @@ IndexOutOfBounds_1 = Index {0} is out of
bounds.
IndicesOutOfBounds_2 = Indices ({0}, {1}) are out of bounds.
InfiniteArgumentValue_1 = Argument \u2018{0}\u2019 can not take an
infinite value.
IntegerOverflow_1 = Integer overflow during {0} bits
arithmetic operation.
+InterruptedWhileWaitingResult = Interrupted while waiting result.
InvalidVersionIdentifier_1 = \u201c{0}\u201d is an invalid version
identifier.
KeyCollision_1 = Key \u201c{0}\u201d is associated twice to
different values.
MandatoryAttribute_2 = Attribute \u201c{0}\u201d is mandatory for
an object of type \u2018{1}\u2019.
diff --git
a/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
b/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
index bdc1ca8..f3a083d 100644
---
a/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
+++
b/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
@@ -23,6 +23,7 @@
#
AlreadyInitialized_1 = \u2018{0}\u2019 est d\u00e9j\u00e0
initialis\u00e9.
AmbiguousName_3 = Le nom \u00ab\u202f{2}\u202f\u00bb est
ambigu\u00eb car il peut \u00eatre interpr\u00e9t\u00e9 comme
\u00ab\u202f{0}\u202f\u00bb ou \u00ab\u202f{1}\u202f\u00bb.
+BackgroundComputationFailed = Le calcul en arri\u00e8re-plan a
\u00e9chou\u00e9.
CanIterateOnlyOnce = Cet objet ne peut it\u00e9rer qu\u2019une
seule fois.
CanNotAddToExclusiveSet_2 = Aucun \u00e9l\u00e9ment ne peut \u00eatre
ajout\u00e9 \u00e0 cet ensemble car les propri\u00e9t\u00e9s \u2018{0}\u2019 et
\u2018{1}\u2019 sont mutuellement exclusives.
CanNotAssign_2 = Ne peut pas assigner
\u00ab\u202f{1}\u202f\u00bb \u00e0 \u00ab\u202f{0}\u202f\u00bb.
@@ -106,6 +107,7 @@ IndexOutOfBounds_1 = L\u2019index {0} est en
dehors des limites p
IndicesOutOfBounds_2 = Les index ({0}, {1}) sont en dehors des
limites permises.
InfiniteArgumentValue_1 = L\u2019argument \u2018{0}\u2019 ne peut
pas prendre une valeur infinie.
IntegerOverflow_1 = D\u00e9passement d\u2019entier lors
d\u2019une op\u00e9ration arithm\u00e9tique sur {0} bits.
+InterruptedWhileWaitingResult = Interrompu pendant l\u2019attente du
r\u00e9sultat.
InvalidVersionIdentifier_1 = \u00ab\u202f{0}\u202f\u00bb n\u2019est pas
un identifiant de version valide.
KeyCollision_1 = La cl\u00e9 \u00ab\u202f{0}\u202f\u00bb
est associ\u00e9e deux fois \u00e0 des valeurs diff\u00e9rentes.
MandatoryAttribute_2 = L\u2019attribut
\u00ab\u202f{0}\u202f\u00bb est obligatoire pour un objet de type
\u2018{1}\u2019.