code: @Override
      public void writeTo(ErrorMessage errorMessage,
                          Class<?> type,
                          Type genericType,
                          Annotation[] annotations,
                          MediaType mediaType,
                          MultivaluedMap<String, Object> httpHeaders,
                          OutputStream entityStream) throws IOException, WebApplicationException {
          ContainerRequestContext request = requestProvider.get();
          int status = errorMessage.getStatus();
  
          String tplName = getErrorTemplate(status);
          if (StringUtils.isBlank(tplName)) {
              if (StringUtils.isBlank(defaultErrorTemplate)) {
                  if (status < 500) {
                      switch (status) {
                          case 401:
                          case 403:
                          case 405:
                          case 406:
                          case 415:
                              tplName = DEFAULT_400_BLACK_ERROR_PAGE;
                              break;
                          default:
                              tplName = DEFAULT_400_ORANGE_ERROR_PAGE;
                      }
                  } else {
                      switch (status) {
                          case 501:
                              tplName = DEFAULT_500_PURPLE_ERROR_PAGE;
                              break;
                          default:
                              tplName = DEFAULT_500_RED_PRODUCT_ERROR_PAGE;
                      }
                  }
              } else {
                  tplName = defaultErrorTemplate;
              }
          }
          Viewable viewable = createViewable(tplName, request, status, errorMessage.getThrowable(), errorMessage);
          writeViewable(viewable, mediaType, httpHeaders, entityStream);
      }
docs: {@inheritDoc}