summaryrefslogtreecommitdiffstats
path: root/infra/translate-impl/src/main/java/io/fd
diff options
context:
space:
mode:
Diffstat (limited to 'infra/translate-impl/src/main/java/io/fd')
-rw-r--r--infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/GenericListReader.java6
-rw-r--r--infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/GenericReader.java6
-rw-r--r--infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/write/GenericListWriter.java18
-rw-r--r--infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/write/GenericWriter.java20
4 files changed, 40 insertions, 10 deletions
diff --git a/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/GenericListReader.java b/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/GenericListReader.java
index c6e7f3cb5..d8accec91 100644
--- a/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/GenericListReader.java
+++ b/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/GenericListReader.java
@@ -106,7 +106,11 @@ public final class GenericListReader<C extends DataObject & Identifiable<K>, K e
public void readCurrentAttributes(@Nonnull final InstanceIdentifier<C> id, @Nonnull final B builder,
@Nonnull final ReadContext ctx)
throws ReadFailedException {
- customizer.readCurrentAttributes(id, builder, ctx);
+ try {
+ customizer.readCurrentAttributes(id, builder, ctx);
+ } catch (RuntimeException e) {
+ throw new ReadFailedException(id, e);
+ }
}
@Override
diff --git a/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/GenericReader.java b/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/GenericReader.java
index 1c638317a..f60c8f137 100644
--- a/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/GenericReader.java
+++ b/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/GenericReader.java
@@ -54,7 +54,11 @@ public final class GenericReader<C extends DataObject, B extends Builder<C>> ext
public void readCurrentAttributes(@Nonnull final InstanceIdentifier<C> id,
@Nonnull final B builder,
@Nonnull final ReadContext ctx) throws ReadFailedException {
- customizer.readCurrentAttributes(id, builder, ctx);
+ try {
+ customizer.readCurrentAttributes(id, builder, ctx);
+ } catch (RuntimeException e) {
+ throw new ReadFailedException(id, e);
+ }
}
@Override
diff --git a/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/write/GenericListWriter.java b/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/write/GenericListWriter.java
index f61812931..4e05ce018 100644
--- a/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/write/GenericListWriter.java
+++ b/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/write/GenericListWriter.java
@@ -46,20 +46,32 @@ public final class GenericListWriter<D extends DataObject & Identifiable<K>, K e
@Override
protected void writeCurrentAttributes(@Nonnull final InstanceIdentifier<D> id, @Nonnull final D data,
@Nonnull final WriteContext ctx) throws WriteFailedException {
- customizer.writeCurrentAttributes(id, data, ctx);
+ try {
+ customizer.writeCurrentAttributes(id, data, ctx);
+ } catch (RuntimeException e) {
+ throw new WriteFailedException.CreateFailedException(id, data, e);
+ }
}
@Override
protected void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<D> id, @Nonnull final D dataBefore,
@Nonnull final WriteContext ctx) throws WriteFailedException {
- customizer.deleteCurrentAttributes(id, dataBefore, ctx);
+ try {
+ customizer.deleteCurrentAttributes(id, dataBefore, ctx);
+ } catch (RuntimeException e) {
+ throw new WriteFailedException.DeleteFailedException(id, e);
+ }
}
@Override
protected void updateCurrentAttributes(@Nonnull final InstanceIdentifier<D> id, @Nonnull final D dataBefore,
@Nonnull final D dataAfter, @Nonnull final WriteContext ctx)
throws WriteFailedException {
- customizer.updateCurrentAttributes(id, dataBefore, dataAfter, ctx);
+ try {
+ customizer.updateCurrentAttributes(id, dataBefore, dataAfter, ctx);
+ } catch (RuntimeException e) {
+ throw new WriteFailedException.UpdateFailedException(id, dataBefore, dataAfter, e);
+ }
}
@Override
diff --git a/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/write/GenericWriter.java b/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/write/GenericWriter.java
index 486da9b4a..30d15e370 100644
--- a/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/write/GenericWriter.java
+++ b/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/write/GenericWriter.java
@@ -40,15 +40,21 @@ public final class GenericWriter<D extends DataObject> extends AbstractGenericWr
@Override
protected void writeCurrentAttributes(@Nonnull final InstanceIdentifier<D> id, @Nonnull final D data,
@Nonnull final WriteContext ctx) throws WriteFailedException {
- // TODO wrap all customizer invocations in try catch, and wrap runtime exceptions in ReadFailed
- // TODO same for readers
- customizer.writeCurrentAttributes(id, data, ctx);
+ try {
+ customizer.writeCurrentAttributes(id, data, ctx);
+ } catch (RuntimeException e) {
+ throw new WriteFailedException.CreateFailedException(id, data, e);
+ }
}
@Override
protected void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<D> id, @Nonnull final D dataBefore,
@Nonnull final WriteContext ctx) throws WriteFailedException {
- customizer.deleteCurrentAttributes(id, dataBefore, ctx);
+ try {
+ customizer.deleteCurrentAttributes(id, dataBefore, ctx);
+ } catch (RuntimeException e) {
+ throw new WriteFailedException.DeleteFailedException(id, e);
+ }
}
@Override
@@ -56,6 +62,10 @@ public final class GenericWriter<D extends DataObject> extends AbstractGenericWr
@Nonnull final D dataBefore,
@Nonnull final D dataAfter,
@Nonnull final WriteContext ctx) throws WriteFailedException {
- customizer.updateCurrentAttributes(id, dataBefore, dataAfter, ctx);
+ try {
+ customizer.updateCurrentAttributes(id, dataBefore, dataAfter, ctx);
+ } catch (RuntimeException e) {
+ throw new WriteFailedException.UpdateFailedException(id, dataBefore, dataAfter, e);
+ }
}
}