aboutsummaryrefslogtreecommitdiff
path: root/core/file_io.lua
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2010-10-28 17:34:38 -0400
committermitchell <70453897+667e-11@users.noreply.github.com>2010-10-28 17:34:38 -0400
commit8eb22e6443ad10009dd4c89e77a593eb91bab19b (patch)
treecda243fc612cb8c732fc7aba4ebdfbe819cf156f /core/file_io.lua
parent91d986b356ef98d214f99efdce1d1a998e8a419b (diff)
downloadtextadept-8eb22e6443ad10009dd4c89e77a593eb91bab19b.tar.gz
textadept-8eb22e6443ad10009dd4c89e77a593eb91bab19b.zip
Display expected error messages in file IO.
Diffstat (limited to 'core/file_io.lua')
-rw-r--r--core/file_io.lua8
1 files changed, 5 insertions, 3 deletions
diff --git a/core/file_io.lua b/core/file_io.lua
index 6a1735e8..b6643f64 100644
--- a/core/file_io.lua
+++ b/core/file_io.lua
@@ -125,11 +125,13 @@ local function open_helper(utf8_filename)
local text
local filename = utf8_filename:iconv(_CHARSET, 'UTF-8')
- local f = io.open(filename, 'rb')
+ local f, err = io.open(filename, 'rb')
if f then
text = f:read('*all')
f:close()
if not text then return end -- filename exists, but can't read it
+ else
+ error(err)
end
local buffer = new_buffer()
if text then
@@ -206,7 +208,7 @@ local function reload(buffer)
local first_visible_line = buffer.first_visible_line
local filename = buffer.filename:iconv(_CHARSET, 'UTF-8')
local f, err = io.open(filename, 'rb')
- if not f then return end
+ if not f then error(err) end
local text = f:read('*all')
f:close()
local encoding, encoding_bom = buffer.encoding, buffer.encoding_bom
@@ -223,7 +225,7 @@ end
-- LuaDoc is in core/.buffer.lua.
local function set_encoding(buffer, encoding)
gui.check_focused_buffer(buffer)
- if not buffer.encoding then error('Cannot change binary file encoding') end
+ if not buffer.encoding then error(L('Cannot change binary file encoding')) end
local pos = buffer.current_pos
local first_visible_line = buffer.first_visible_line
local text = buffer:get_text(buffer.length)