diff --git a/resulter-core/src/main/java/com/iamceph/resulter/core/pack/Packeto.java b/resulter-core/src/main/java/com/iamceph/resulter/core/pack/Packeto.java index e9cede0..e0d32a4 100644 --- a/resulter-core/src/main/java/com/iamceph/resulter/core/pack/Packeto.java +++ b/resulter-core/src/main/java/com/iamceph/resulter/core/pack/Packeto.java @@ -6,9 +6,11 @@ import com.iamceph.resulter.core.DataResultable; import com.iamceph.resulter.core.Resultable; import com.iamceph.resulter.core.model.ResultableData; + import lombok.experimental.UtilityClass; import lombok.val; import lombok.var; + import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -50,8 +52,14 @@ public ResultableData pack(@NotNull DataResultable input) { if (data instanceof ProtoWrapper) { final var wrapped = (ProtoWrapper) data; final var message = wrapped.asProto(); + if (!(message instanceof ProtoWrapper)) { + val errorResult = DataResultable.fail("Cannot convert data - " + data.getClass().getSimpleName()); + return ResultableData.newBuilder() + .setResult(errorResult.asProto()) + .build(); + } - return buildMessage(input, message); + return buildMessage(input, (Message) message); } val errorResult = DataResultable.fail("Cannot convert data - " + data.getClass().getSimpleName()); diff --git a/resulter-core/src/main/java/com/iamceph/resulter/core/pack/ProtoWrapper.java b/resulter-core/src/main/java/com/iamceph/resulter/core/pack/ProtoWrapper.java index 4d7a9b3..c66a78d 100644 --- a/resulter-core/src/main/java/com/iamceph/resulter/core/pack/ProtoWrapper.java +++ b/resulter-core/src/main/java/com/iamceph/resulter/core/pack/ProtoWrapper.java @@ -1,13 +1,11 @@ package com.iamceph.resulter.core.pack; -import com.google.protobuf.Message; - /** * A wrapper for .proto conversions. * - * @param .proto type of this class + * @param result of the asProto */ -public interface ProtoWrapper { +public interface ProtoWrapper { /** * Wraps current wrapper into a .proto class *