From 4d0b894d37870351052c343f41dca18acfd54194 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Fri, 21 May 2021 01:49:25 -0700 Subject: [PATCH] Java Client: throw exception when assign fails --- .../client/src/main/java/seaweedfs/client/SeaweedWrite.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/other/java/client/src/main/java/seaweedfs/client/SeaweedWrite.java b/other/java/client/src/main/java/seaweedfs/client/SeaweedWrite.java index f8c0c76b6..75d2a0e7e 100644 --- a/other/java/client/src/main/java/seaweedfs/client/SeaweedWrite.java +++ b/other/java/client/src/main/java/seaweedfs/client/SeaweedWrite.java @@ -1,5 +1,6 @@ package seaweedfs.client; +import com.google.common.base.Strings; import com.google.protobuf.ByteString; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; @@ -50,6 +51,11 @@ public class SeaweedWrite { .setTtlSec(0) .setPath(path) .build()); + + if (!Strings.isNullOrEmpty(response.getError())) { + throw new IOException(response.getError()); + } + String fileId = response.getFileId(); String auth = response.getAuth();