changeset 1094:cb4c20fce7d0

add "response_code" and "response_message" to http url luan exceptions
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 24 Jan 2017 14:14:43 -0700
parents a656fa45e315
children 2443152dc2f1
files src/luan/modules/url/LuanUrl.java
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
diff -r a656fa45e315 -r cb4c20fce7d0 src/luan/modules/url/LuanUrl.java
--- a/src/luan/modules/url/LuanUrl.java	Sun Jan 08 21:13:45 2017 -0700
+++ b/src/luan/modules/url/LuanUrl.java	Tue Jan 24 14:14:43 2017 -0700
@@ -273,13 +273,19 @@
 		try {
 			return httpCon.getInputStream();
 		} catch(IOException e) {
+			int responseCode = httpCon.getResponseCode();
+			String responseMessage = httpCon.getResponseMessage();
 			InputStream is = httpCon.getErrorStream();
 			if( is == null )
 				throw e;
 			Reader in = new InputStreamReader(is);
 			String msg = Utils.readAll(in);
 			in.close();
-			throw new LuanException(msg,e);
+			LuanException le = new LuanException(msg,e);
+			LuanTable tbl = le.table();
+			tbl.rawPut("response_code",responseCode);
+			tbl.rawPut("response_message",responseMessage);
+			throw le;
 		}
 	}