Skip to content

Commit 8f0659c

Browse files
committed
Parse merkle node errors and throw accordingly
1 parent 07ca478 commit 8f0659c

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/main/java/io/ipfs/api/MerkleNode.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ public static MerkleNode fromJSON(Object rawjson) {
7070
Optional<String> largeSize = rawSize instanceof String ?
7171
Optional.of((String) json.get("Size")) :
7272
Optional.empty();
73+
if ("error".equals(json.get("Type")))
74+
throw new IllegalStateException("Remote IPFS error: " + json.get("Message"));
7375
Optional<Integer> type = json.containsKey("Type") ?
7476
Optional.of((Integer) json.get("Type")) :
7577
Optional.empty();

0 commit comments

Comments
 (0)