====== Vibemosphere Cat Error Server Pages ====== Error pages with a cat picture per status code (403, 404, 500 ...) for every web application, and error logging with a correlation id to JSON files or a database (JNDI data source). ^ Id | ''cat-error-pages'' | ^ Role | ''admin'' - needed for the page and the REST API (administrators always may) | ^ Page | **Plugins > Open** (overlay with an X at the top right) or ''/plugins/cat-error-pages/'' | ^ REST | ''/api/plugins/cat-error-pages/...'' and, for callers with the role, ''/plugins/cat-error-pages/...'' | ===== Open the configuration ===== In the administration open **Plugins**, select the row of this plug-in and press **Open**. The page opens in an overlay dialog: close it with the **X** at the top right, with Esc or by clicking outside; //Open in a new tab// next to the title shows it full size. {{vibecat:plugin-cat-error-pages.png?900|Vibemosphere Cat Error Server Pages: the plug-in page in its overlay dialog}} ===== Step by step ===== - Switch the cat error page on (it replaces the Tomcat error report) and choose where the error log goes: JSON files (''yyyy/MM/dd'') and/or a table of a JNDI data source from [[vibecat:datasources|Data sources]]. - Add pictures: the file name prefix names the status codes (''404_...'', ''403_401_...'', ''Other_...''). - Open **Reports > Error report** to see the logged errors with their correlation id. ===== The page in detail ===== {{vibecat:plugin-cat-error-pages-full.png?900|cat-error-pages: first tab, Error pages}} ===== Tabs ===== The page is divided into the tabs **Error pages**, **Preview**, **Pictures**, **Logging**, **Recent errors**. ==== Preview ==== {{vibecat:plugin-cat-error-pages-tab2.png?900|cat-error-pages: tab Preview}} ==== Pictures ==== {{vibecat:plugin-cat-error-pages-tab3.png?900|cat-error-pages: tab Pictures}} ==== Logging ==== {{vibecat:plugin-cat-error-pages-tab4.png?900|cat-error-pages: tab Logging}} ==== Recent errors ==== {{vibecat:plugin-cat-error-pages-tab5.png?900|cat-error-pages: tab Recent errors}} ==== Dialog: Add a status code ==== {{vibecat:plugin-cat-error-pages-dialog.png?900|Vibemosphere Cat Error Server Pages: the dialog of "Add a status code"}} ===== Fields and columns ===== ^ Label ^ Meaning ^ | Status | | | Status codes comma separated, or "Other" | | | Title part of the file name | | | Picture jpg, png, gif, webp, svg - up to 8 MB | | | Folder empty: . Below it: yyyy/MM/dd/HHmmss-SSS_status_reference.json | | | Keep the files for (days, 0 = forever) | | | Data source the JNDI data sources of the administration (page Data sources) | | | Table | | | Log these statuses codes and ranges | | | Except not logged | | | Show the reference on the page | | | ... from status | | | Link on the page | | | Text of the link | | | Find a reference | | | Title | Column of a table | | Message | Column of a table | | Picture | Column of a table | ===== Actions ===== * **Add a status code** * **Default texts** * **Save** * **Show** * **Upload** * **Write a test entry** * **Reload** * **Find** ===== Notes from the page ===== * One page per status code. The picture is chosen by the code in the file name of the picture ("404_..." is for 404) unless you pick one here; the code 0 row is for every other error. A web application with an error page of its own (error-page in its web.xml) keeps it. * The picture of a page: the file name starts with the status codes it is for, then the title: 403_401_Angry cat.jpg is for 403 and 401, Other_Cuddly cat.jpg for every other status. Your own pictures (folder ) win over the pictures of the plug-in. ===== Reference ===== The plug-in is on from the first start: it needs no setting. It puts two **valves** into the request pipeline of the host, so it works for every web application on every port of the web applications: ^ Valve ^ What it does ^ | ''CatErrorPageValve'' | Replaces Tomcat's error report valve (the Valves page then shows the standard one as "replaced by a plug-in"). An error that the web application did not answer with an error page of its own (''error-page'' in its web.xml) gets the cat page: picture, status code, title, message and, for logged errors, the **reference**. A client that sends ''Accept: application/json'' without ''text/html'' (a REST client) gets ''{"status":500,"error":"...","message":"...","correlationId":"...","path":"..."}'' and the header ''X-Correlation-Id''. The pictures are served by the valve from ''/__vibecat/cat/''. | | ''ErrorLogValve'' | The valve of the sample: ''try { next.invoke() } finally { if (status >= 400) log }''. It gives each request a correlation id (request attribute ''dev.vibemosphere.caterror.correlationId'', so a servlet can show it too) and writes the error after the request. The writing is done on a thread of its own: a slow database does not slow the request down (a queue of 2000; what does not fit is counted as dropped). | ==== The reference (correlation id) ==== Format ''yyMMdd-HHmmss-XXXXXX'' (time of the request and six letters without confusing characters, e.g. ''261115-143201-K7QX9M''). By default it is shown on the page for errors **from status 500** that are logged: the user quotes it, and "Recent errors" on the page of the plug-in (or the file / the table row) shows the request, the exception and the stack trace. The setting "Show the reference" can also be //always// or //never//. ==== Where the errors go ==== ^ Sink ^ Details ^ | JSON files | On by default in the data folder of the plug-in (''plugin-data\cat-error-pages\errors''), or a folder of your choice. One file per error in a simple date tree: ''2026\11\15\143201-512_500_261115-143201-K7QX9M.json''. Old days can be deleted automatically (keep for n days). | | Database | A table of a **JNDI data source of the administration** (page Data sources): the data source is defined once for the whole system and used here as a pool of the container. The table (default ''vibecat_error_log'') is created when it is missing (SQL Server, Oracle, PostgreSQL, MySQL / MariaDB, SQLite, H2 and others: the column types follow the database). Columns: ''id'' (the reference), ''occurred'', ''status'', ''method'', ''uri'', ''query_string'', ''host'', ''remote_addr'', ''user_agent'', ''referer'', ''context_path'', ''user_name'', ''message'', ''exception_class'', ''stack_trace'', ''node''. The data source does not have to be switched on for web applications. | Both can be on at the same time. **Which statuses**: by default 400-599 except 401 (the login prompt of a browser) and 404 (the noise of scanners); change it on the page. The query string of the request is part of the record: do not put secrets into URLs. ==== Pictures ==== The pictures are chosen by the **codes in the prefix of the file name**: ''403_401_Angry cat.jpg'' is for 403 and 401, ''404_...'' for 404, ''413_...'' for 413 (request too large), ''429_...'' for 429 (too many requests), ''500_...'' for 500 (and the other 5xx without a picture of their own), ''Other_...'' for everything else. Add your own pictures on the page (they are saved in the folder ''plugin-data\cat-error-pages\images'', or the folder you name) - they win over the pictures of the plug-in. A page can also name a picture directly. Texts and pictures are changed without a restart. ==== REST ==== ''GET|PUT /plugins/cat-error-pages/settings'' (administrator), ''POST /plugins/cat-error-pages/preview'' (''{"code":404,"withId":true}'' answers the HTML), ''POST /plugins/cat-error-pages/test'' (writes a test entry), ''GET /plugins/cat-error-pages/recent?limit=50'', ''GET /plugins/cat-error-pages/record?id=...''. ==== Switching it off ==== The checkbox at the top of the page: the valves stay in the pipeline but pass every request on and Tomcat's standard error report is used again. To remove the plug-in completely, delete ''vibemosphere-cat-error-pages.jar'' from the ''plugins'' folder and restart. [[vibecat:plugins:start|All plug-ins]]