docs: private void errorHandling(CmsObject cms, HttpServletRequest req, HttpServletResponse res, Throwable t) {
  
          // remove the controller attribute from the request
          CmsFlexController.removeController(req);
  
          boolean canWrite = (!res.isCommitted() && !res.containsHeader("Location"));
          int status = -1;
          boolean isGuest = true;
  
          if (t instanceof ServletException) {
              ServletException s = (ServletException)t;
              if (s.getRootCause() != null) {
                  t = s.getRootCause();
              }
              LOG.error(t.getLocalizedMessage() + " rendering URL " + req.getRequestURL(), t);
          } else if (t instanceof CmsSecurityException) {
              LOG.warn(t.getLocalizedMessage() + " rendering URL " + req.getRequestURL(), t);
              // access error - display login dialog
              if (canWrite) {
                  try {
                      m_authorizationHandler.requestAuthorization(req, res, getLoginFormURL(req, res));
                  } catch (IOException ioe) {
                      LOG.debug("Error calling authorization handler.", ioe);
                  }
                  return;
              }
          } else if (t instanceof CmsDbEntryNotFoundException) {
              LOG.warn(t.getLocalizedMessage() + " rendering URL " + req.getRequestURL(), t);
              // user or group does not exist
              status = HttpServletResponse.SC_SERVICE_UNAVAILABLE;
              isGuest = false;
          } else if (t instanceof CmsVfsResourceNotFoundException) {
              LOG.warn(t.getLocalizedMessage() + " rendering URL " + req.getRequestURL(), t);
              // file not found - display 404 error.
              status = HttpServletResponse.SC_NOT_FOUND;
          } else if (t instanceof CmsException) {
              LOG.error(t.getLocalizedMessage() + " rendering URL " + req.getRequestURL(), t);
              if (t.getCause() != null) {
                  t = t.getCause();
              }
          } else if (t.getClass().getName().equals("org.apache.catalina.connector.ClientAbortException")) {
              // only log to debug channel any exceptions caused by a client abort - this is tomcat specific
              LOG.debug(t.getLocalizedMessage() + " rendering URL " + req.getRequestURL(), t);
          } else {
              LOG.error(t.getLocalizedMessage() + " rendering URL " + req.getRequestURL(), t);
          }
  
          if (status < 1) {
              // error code not set - set "internal server error" (500)
              status = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
          }
          res.setStatus(status);
  
          try {
              if ((cms != null) && (cms.getRequestContext().getCurrentUser() != null)) {
                  isGuest = isGuest
                      && (cms.getRequestContext().getCurrentUser().isGuestUser()
                          || cms.userInGroup(
                              cms.getRequestContext().getCurrentUser().getName(),
                              OpenCms.getDefaultUsers().getGroupGuests()));
              }
          } catch (CmsException e) {
              // result is false
              LOG.error(e.getLocalizedMessage(), e);
          }
  
          if (canWrite) {
              res.setContentType("text/html");
              CmsRequestUtil.setNoCacheHeaders(res);
              if ((status != 404)
                  && !isGuest
                  && (cms != null)
                  && (!CmsJsonPartFilter.isJsonRequest(req))
                  && !cms.getRequestContext().getCurrentProject().isOnlineProject()) {
                  try {
                      res.setStatus(HttpServletResponse.SC_OK);
                      res.getWriter().print(CmsErrorUI.getBootstrapPage(cms, t, req));
                  } catch (IOException e) {
                      // can be ignored
                      LOG.error(e.getLocalizedMessage(), e);
                  }
              } else {
                  try {
                      res.sendError(status, t.toString());
                  } catch (IOException e) {
                      // can be ignored
                      LOG.error(e.getLocalizedMessage(), e);
                  }
              }
          }
      }