Class PsaRstApiErrFac


  • public class PsaRstApiErrFac
    extends java.lang.Object
    REST API: error factory
    Since:
    21.06.2023
    Author:
    weiland
    • Constructor Detail

      • PsaRstApiErrFac

        public PsaRstApiErrFac​(PsaRstApiErrCod code)
        Constructor
        Parameters:
        code - error code
      • PsaRstApiErrFac

        public PsaRstApiErrFac​(javax.ws.rs.core.Response.Status status)
        Constructor
        Parameters:
        status - status code
    • Method Detail

      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
        See Also:
        Object.toString()
      • setErrorCode

        public PsaRstApiErrFac setErrorCode​(java.lang.String code)
        set the error code
        Parameters:
        code - code
        Returns:
        this
      • setErrorMessage

        public PsaRstApiErrFac setErrorMessage​(java.lang.String message)
        set the error message
        Parameters:
        message - message
        Returns:
        this
      • addDetail

        public PsaRstApiErrFac addDetail​(java.lang.String key,
                                         java.lang.String value)
        add a detail
        Parameters:
        key - key
        value - value
        Returns:
        this
      • buildError

        public PsaRstApiErr buildError()
        build a new error instance where the placeholders in the message ore replaced
        Returns:
        error
      • throwError

        public void throwError()
                        throws javax.ws.rs.ClientErrorException,
                               javax.ws.rs.ServerErrorException
        throw a web exception
        Throws:
        javax.ws.rs.ClientErrorException - if the response has a 4XX status
        javax.ws.rs.ServerErrorException - if the response has a 5XX status
        java.lang.RuntimeException - if the response has not a status of 4XX or 5XX