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

    https://github.com/apache/spark/pull/21644#discussion_r198560296
  
    --- 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 --
    
    yes, indeed they do. Not too much code but
    ```
    throw new ForbiddenException(raw"""user "$user" is not authorized""")
    ```
    would become
    ```
    throw new ForbiddenException(UIUtils.buildErrorResponse(
                Response.Status.FORBIDDEN, raw"""user "$user" is not 
authorized"""))
    ```
    
    what do you think? Shall we do the refactor?


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to