Github user mgaido91 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21644#discussion_r198554094
  
    --- Diff: 
core/src/main/scala/org/apache/spark/status/api/v1/ApiRootResource.scala ---
    @@ -148,38 +148,21 @@ private[v1] trait BaseAppResource extends 
ApiRequestContext {
     }
     
     private[v1] class ForbiddenException(msg: String) extends 
WebApplicationException(
    -  Response.status(Response.Status.FORBIDDEN).entity(msg).build())
    +    UIUtils.buildErrorResponse(Response.Status.FORBIDDEN, msg))
     
     private[v1] class NotFoundException(msg: String) extends 
WebApplicationException(
    -  new NoSuchElementException(msg),
    -    Response
    -      .status(Response.Status.NOT_FOUND)
    -      .entity(ErrorWrapper(msg))
    -      .build()
    -)
    +    new NoSuchElementException(msg),
    +    UIUtils.buildErrorResponse(Response.Status.NOT_FOUND, msg))
     
     private[v1] class ServiceUnavailable(msg: String) extends 
WebApplicationException(
    -  new ServiceUnavailableException(msg),
    -  Response
    -    .status(Response.Status.SERVICE_UNAVAILABLE)
    -    .entity(ErrorWrapper(msg))
    -    .build()
    -)
    +    new ServiceUnavailableException(msg),
    --- End diff --
    
    thanks for your review. Sure I can do the refactor, but the helper method 
would be needed anyway. Indeed, the problem which was present before the PR is 
that we are not specifying the type of the response, so it takes the type which 
is produced. And in the default exceptions you mentioned the `Response` is 
built without setting the type, so we still need to pass them the `Response` we 
build in the helper method.
    
    I will follow your suggestion (so I'll clean up our exceptions using the 
jax ones), but keeping the helper method for this reason. Thanks.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to