changeset 1519:3ebf9781707c

http error handling
author Franklin Schmidt <fschmidt@gmail.com>
date Fri, 19 Jun 2020 20:10:47 -0600
parents f989778ca9e1
children d9a5405a3102
files src/luan/modules/url/LuanUrl.java
diffstat 1 files changed, 11 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/luan/modules/url/LuanUrl.java	Fri Jun 19 17:50:25 2020 -0600
+++ b/src/luan/modules/url/LuanUrl.java	Fri Jun 19 20:10:47 2020 -0600
@@ -326,16 +326,22 @@
 					throw new LuanException(pe);
 				}
 			}
+			String msg = "" + responseCode;
 			String responseMessage = httpCon.getResponseMessage();
+			if( responseMessage != null )
+				msg += " - " + responseMessage;
+			String responseContent = null;
 			InputStream is = httpCon.getErrorStream();
-			if( is == null )
-				throw e;
-			Reader in = new InputStreamReader(is);
-			String msg = IoUtils.readAll(in);
-			in.close();
+			if( is != null ) {
+				Reader in = new InputStreamReader(is);
+				responseContent = IoUtils.readAll(in);
+				in.close();
+				msg += "\n" + responseContent;
+			}
 			LuanException le = new LuanException(msg,e);
 			le.put("response_code",responseCode);
 			le.put("response_message",responseMessage);
+			le.put("response_content",responseContent);
 			throw le;
 		}
 	}