changeset 1349:0cceff521abb

IO error handling
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 27 Feb 2019 12:30:46 -0700
parents af478a1bd23d
children d8754a50adf1
files src/luan/cmd_line.luan src/luan/modules/IoLuan.java src/luan/modules/url/LuanUrl.java
diffstat 3 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/luan/cmd_line.luan	Mon Feb 25 13:34:56 2019 -0700
+++ b/src/luan/cmd_line.luan	Wed Feb 27 12:30:46 2019 -0700
@@ -22,7 +22,7 @@
 	end
 	try {
 		function()
-			local main_file = load_file(file)
+			local main_file = load_file(file) or error("file '"..file.."' not found")
 			local rtn = pack( main_file( unpack(Luan.arg) ) )
 			if rtn.n > 0 then
 				print( unpack(rtn) )
--- a/src/luan/modules/IoLuan.java	Mon Feb 25 13:34:56 2019 -0700
+++ b/src/luan/modules/IoLuan.java	Wed Feb 27 12:30:46 2019 -0700
@@ -193,6 +193,10 @@
 				return false;
 			} catch(UnknownHostException e) {
 				return false;
+			} catch(LuanException e) {
+				if( e.getCause() instanceof FileNotFoundException )
+					return false;
+				throw e;
 			}
 		}
 
--- a/src/luan/modules/url/LuanUrl.java	Mon Feb 25 13:34:56 2019 -0700
+++ b/src/luan/modules/url/LuanUrl.java	Wed Feb 27 12:30:46 2019 -0700
@@ -274,8 +274,8 @@
 	{
 		try {
 			return httpCon.getInputStream();
-		} catch(FileNotFoundException e) {
-			throw e;
+//		} catch(FileNotFoundException e) {
+//			throw e;
 		} catch(IOException e) {
 			int responseCode = httpCon.getResponseCode();
 			if( responseCode == 401 && authUsername != null && authorization==null ) {