diff website/src/manual.html.luan @ 1316:11d3640e739d

load_file returns nil for missing file
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 31 Jan 2019 04:26:23 -0700
parents 693da73c8a2f
children 3860ed4b8552
line wrap: on
line diff
--- a/website/src/manual.html.luan	Wed Jan 30 01:21:49 2019 -0700
+++ b/website/src/manual.html.luan	Thu Jan 31 04:26:23 2019 -0700
@@ -1817,7 +1817,8 @@
 
 <pre>
 	function Luan.do_file(uri)
-		return <a href="#Luan.load_file">Luan.load_file</a>(uri)()
+		local fn = <a href="#Luan.load_file">Luan.load_file</a>(uri) or <a href="#Luan.error">Luan.error</a>("file '"..uri.."' not found")
+		return fn()
 	end
 </pre>
 
@@ -1930,7 +1931,9 @@
 	function Luan.load_file(file_uri)
 		file_uri = file_uri or "stdin:"
 		local f = Io.uri(file_uri)
-		f.exists() or <a href="#Luan.error">Luan.error</a>("file '"..file_uri.."' not found")
+		if not f.exists() then
+			return nil
+		end
 		return <a href="#Luan.load">Luan.load</a>( f.read_text(), file_uri )
 	end
 </pre>