Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public void onFailure(Exception ex, ServiceContext context) throws IOException {
super.onFailure(ex, context);
if (ex instanceof WebApplicationException) {
throw (WebApplicationException) ex;
} else if (ex instanceof IOException) {
throw (IOException) ex;
} else {
throw new IOException(ex);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import jakarta.ws.rs.ext.ExceptionMapper;
import jakarta.ws.rs.ext.Provider;

import org.apache.zeppelin.notebook.exception.NotePathAlreadyExistsException;
import org.apache.zeppelin.utils.ExceptionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -34,6 +36,8 @@ public class WebApplicationExceptionMapper implements ExceptionMapper<Throwable>
public Response toResponse(Throwable exception) {
if (exception instanceof WebApplicationException) {
return ((WebApplicationException) exception).getResponse();
} else if (exception instanceof NotePathAlreadyExistsException) {
return ExceptionUtils.jsonResponseContent(Response.Status.CONFLICT, exception.getMessage());
} else {
LOGGER.error("Error response", exception);
// Return generic error message to prevent information disclosure
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,9 @@ public String importNote(String notePath,
callback.onSuccess(note, context);
return note.getId();
});

} catch (NotePathAlreadyExistsException e) {
callback.onFailure(new NotePathAlreadyExistsException("Fail to import note: " + e.getMessage(), e), context);
return null;
} catch (IOException e) {
callback.onFailure(new IOException("Fail to import note: " + e.getMessage(), e), context);
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,8 @@ public NotePathAlreadyExistsException(final String message) {
super(message);
}

public NotePathAlreadyExistsException(final String message, final Throwable cause) {
super(message, cause);
}

}
Loading