Fix error behavior.
This commit is contained in:
@@ -270,7 +270,7 @@ public class IoLib extends OneArgFunction {
|
||||
f = checkfile(env);
|
||||
return freadline(f);
|
||||
}
|
||||
} catch ( Exception ioe ) {
|
||||
} catch ( IOException ioe ) {
|
||||
return errorresult(ioe);
|
||||
}
|
||||
return NONE;
|
||||
@@ -319,10 +319,14 @@ public class IoLib extends OneArgFunction {
|
||||
return varargsOf(NIL, valueOf(errortext));
|
||||
}
|
||||
|
||||
private Varargs lines(final File f) throws Exception {
|
||||
IoLib iter = (IoLib) getClass().newInstance();
|
||||
iter.setfenv(f);
|
||||
return iter.bindv("lnext",LINES_ITER);
|
||||
private Varargs lines(final File f) {
|
||||
try {
|
||||
IoLib iter = (IoLib) getClass().newInstance();
|
||||
iter.setfenv(f);
|
||||
return iter.bindv("lnext",LINES_ITER);
|
||||
} catch ( Exception e ) {
|
||||
return error("lines: "+e);
|
||||
}
|
||||
}
|
||||
|
||||
private static Varargs iowrite(File f, Varargs args) throws IOException {
|
||||
|
||||
@@ -111,7 +111,11 @@ print( "a:read", ( a:read(7) ) )
|
||||
print( "b:read", ( b:read(7) ) )
|
||||
--]]
|
||||
|
||||
local pcall = function(...) return ( pcall(...) )end
|
||||
local pcall = function(...)
|
||||
local s,e = pcall(...)
|
||||
if s then return s end
|
||||
return s,e:match("closed")
|
||||
end
|
||||
|
||||
print( 'a:close', pcall( a.close, a ) )
|
||||
print( 'a:write', pcall( a.write, a, 'eee') )
|
||||
|
||||
Reference in New Issue
Block a user