aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/textadept/command_entry.lua2
-rw-r--r--modules/textadept/file_types.lua2
-rw-r--r--modules/textadept/find.lua2
-rw-r--r--modules/textadept/keys.lua4
-rw-r--r--modules/textadept/menu.lua5
5 files changed, 7 insertions, 8 deletions
diff --git a/modules/textadept/command_entry.lua b/modules/textadept/command_entry.lua
index 6d2b58dc..0302aa67 100644
--- a/modules/textadept/command_entry.lua
+++ b/modules/textadept/command_entry.lua
@@ -101,7 +101,7 @@ local env = setmetatable({}, {
function M.execute_lua(code)
if code:sub(1, 1) == '=' then code = 'return '..code:sub(2) end
local f, err = load(code, nil, 'bt', env)
- if err then error(err) end
+ assert(f, err)
local result = f()
if result ~= nil then ui.print(result) end
events.emit(events.UPDATE_UI)
diff --git a/modules/textadept/file_types.lua b/modules/textadept/file_types.lua
index fe0c8adc..df5918ba 100644
--- a/modules/textadept/file_types.lua
+++ b/modules/textadept/file_types.lua
@@ -99,7 +99,7 @@ local function set_lexer_functions()
buffer.get_lexer, buffer.set_lexer = get_lexer, set_lexer
buffer.style_name = setmetatable({}, {
__index = function(t, style_num) -- LuaDoc is in core/.buffer.luadoc
- if style_num < 0 or style_num > 255 then error('0 <= style_num < 256') end
+ assert(style_num >= 0 and style_num <= 255, '0 <= style_num < 256')
return buffer:private_lexer_call(style_num)
end,
__newindex = function() error('read-only property') end
diff --git a/modules/textadept/find.lua b/modules/textadept/find.lua
index 3d82ad1b..be6d767c 100644
--- a/modules/textadept/find.lua
+++ b/modules/textadept/find.lua
@@ -271,7 +271,7 @@ local function replace(rtext)
local ok, rtext = pcall(rtext.gsub, rtext, '%%(%b())', function(code)
code = code:gsub('[\a\b\f\n\r\t\v\\]', escapes)
local ok, result = pcall(load('return '..code))
- if not ok then error(result) end
+ assert(ok, result)
return result:gsub('\\[abfnrtv\\]', escapes)
end)
if ok then
diff --git a/modules/textadept/keys.lua b/modules/textadept/keys.lua
index 7a341977..dcf4ea87 100644
--- a/modules/textadept/keys.lua
+++ b/modules/textadept/keys.lua
@@ -276,12 +276,12 @@ M.utils = {
open_webpage = function(url)
if WIN32 then
local p = io.popen(string.format('start "" "%s"', url))
- if not p then error(_L['Error loading webpage:']..url) end
+ assert(p, _L['Error loading webpage:']..url)
p:close()
else
local _, _, code = os.execute(string.format(OSX and 'open "file://%s"' or
'xdg-open "%s" &', url))
- if code ~= 0 then error(_L['Error loading webpage:']..url) end
+ assert(code == 0, _L['Error loading webpage:']..url)
end
end,
cut_to_eol = function()
diff --git a/modules/textadept/menu.lua b/modules/textadept/menu.lua
index ea4b9db1..3a0348ab 100644
--- a/modules/textadept/menu.lua
+++ b/modules/textadept/menu.lua
@@ -379,9 +379,8 @@ end
events.connect(events.MENU_CLICKED, function(menu_id)
local actions = menu_id < 1000 and menu_actions or contextmenu_actions
local action = actions[menu_id < 1000 and menu_id or menu_id - 1000]
- if type(action) ~= 'function' and type(action) ~= 'table' then
- error(_L['Unknown command:']..' '..tostring(action))
- end
+ assert(type(action) == 'function' or type(action) == 'table',
+ _L['Unknown command:']..' '..tostring(action))
keys.run_command(action, type(action))
end)