Browse Source

Change signalcall to protectedcall in console

Even though they kind of do the same (calling function in protected
mode), @edubart suggested to use a different function for the sake of
readability.
Konrad Kuśnierz 5 years ago
parent
commit
7f2f70e1a6
2 changed files with 11 additions and 1 deletions
  1. 10
    0
      modules/corelib/util.lua
  2. 1
    1
      modules/game_console/console.lua

+ 10
- 0
modules/corelib/util.lua View File

@@ -296,6 +296,16 @@ function numbertoboolean(number)
296 296
   end
297 297
 end
298 298
 
299
+function protectedcall(func, ...)
300
+  local status, ret = pcall(func, ...)
301
+  if status then
302
+    return ret
303
+  end
304
+
305
+  perror(ret)
306
+  return false
307
+end
308
+
299 309
 function signalcall(param, ...)
300 310
   if type(param) == 'function' then
301 311
     local status, ret = pcall(param, ...)

+ 1
- 1
modules/game_console/console.lua View File

@@ -694,7 +694,7 @@ function processChannelTabMenu(tab, mousePos, mouseButton)
694 694
       table.insert(lines, 1, os.date('\nChannel saved at %a %b %d %H:%M:%S %Y'))
695 695
 
696 696
       if g_resources.fileExists(filepath) then
697
-        table.insert(lines, 1, signalcall(g_resources.readFileContents, filepath) or '')
697
+        table.insert(lines, 1, protectedcall(g_resources.readFileContents, filepath) or '')
698 698
       end
699 699
 
700 700
       g_resources.writeFileContents(filepath, table.concat(lines, '\n'))

Loading…
Cancel
Save