diff src/goodjava/webserver/Connection.java @ 1736:a02a75e3daa8

webserver error handling
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 16 Oct 2022 11:44:23 -0600
parents fa066aaa068c
children 9713f7fd50b3
line wrap: on
line diff
--- a/src/goodjava/webserver/Connection.java	Sun Oct 02 17:32:00 2022 -0600
+++ b/src/goodjava/webserver/Connection.java	Sun Oct 16 11:44:23 2022 -0600
@@ -26,6 +26,7 @@
 	}
 
 	private void handle() {
+		String rawHead = "";
 		try {
 			Request request = new Request();
 			Response response;
@@ -61,7 +62,7 @@
 							left = a.length - size;
 						}
 					}
-					String rawHead = new String(a,0,endOfHeader);
+					rawHead = new String(a,0,endOfHeader);
 					//System.out.println(rawHead);
 					request.rawHead = rawHead;
 					RequestParser parser = new RequestParser(request);
@@ -124,7 +125,10 @@
 			out.close();
 			socket.close();
 		} catch(IOException e) {
-			logger.info("",e);
+			logger.info(rawHead.trim()+"\n",e);
+		} catch(RuntimeException e) {
+			logger.error(rawHead.trim()+"\n",e);
+			throw e;
 		}
 	}