Skip to content

Commit 820890c

Browse files
Merge pull request #1015 from data-integrations/CDAP-21203_cherry
[cherry-pick][6.11][CDAP-21203] : handling unauthorized exception to give correct status code
2 parents 1888aec + a730d63 commit 820890c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

wrangler-service/src/main/java/io/cdap/wrangler/service/common/AbstractWranglerHandler.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import io.cdap.cdap.api.service.http.HttpServiceRequest;
2323
import io.cdap.cdap.api.service.http.HttpServiceResponder;
2424
import io.cdap.cdap.api.service.worker.RemoteExecutionException;
25+
import io.cdap.cdap.security.spi.authorization.UnauthorizedException;
2526
import io.cdap.cdap.spi.data.transaction.TransactionRunners;
2627
import io.cdap.wrangler.api.RecipeException;
2728
import io.cdap.wrangler.dataset.connections.ConnectionNotFoundException;
@@ -215,6 +216,8 @@ protected void respond(HttpServiceResponder responder, String namespace,
215216
} catch (RemoteExecutionException e) {
216217
responder.sendJson(getErrorCode(e.getCause().getRemoteExceptionClassName()),
217218
new io.cdap.wrangler.proto.workspace.v2.ServiceResponse<>(e.getMessage()));
219+
} catch (UnauthorizedException e) {
220+
responder.sendJson(e.getStatusCode(), new io.cdap.wrangler.proto.workspace.v2.ServiceResponse<>(e.getMessage()));
218221
} catch (Throwable t) {
219222
responder.sendJson(HttpURLConnection.HTTP_INTERNAL_ERROR,
220223
new io.cdap.wrangler.proto.workspace.v2.ServiceResponse<>((t.getMessage())));

0 commit comments

Comments
 (0)