Quantcast
Download
(3 Kb)
Download
Updated: 09/29/17 01:36 PM
Compatibility:
Clockwork City (3.2)
Horns of the Reach (3.1)
Morrowind (3.0)
Updated:09/29/17 01:36 PM
Created:06/25/17 12:21 PM
Monthly downloads:52
Total downloads:280
Favorites:1
MD5:
3.2
LibSafe
Version: 1.008
by: dryzler.elder-geek.net [More]

"Methods for safer addons"

Features:
  • Execute (your) code error handled and logged
  • Make your complete table(s) safe with 1 line of code

Thanks:
  • sirinsidiator, silvereyes333, votan, Ayantir, Shinni, and Dolgubon

Addons that use this lib:
Todo: report logged errors to author function.

1 liners
Code:
--save this in your namespace:
self.libSafe = LibStub("LibSafe").new(self, self.name, self.saveVariablesName, self.debug)

--make your addonTable safe with error logging:
self.libSafe:makeTableSafe()

--make another table safe:
LibStub("LibSafe"):makeTableSafe(workTable)

--make another table safe with error logging:
LibStub("LibSafe"):makeTableSafe(workTable, self.libSafe)
Hint: The functions made safe with the 1 liners don't return success/try as first return value, the just return there return values as coded, so if you have a (big) table, and use the 1 liner, you don't have to touch anything.

ad hock call functions safe
Code:
--call a function of the table that was passed as first parameter to LibSafe.new(self,...):
local try, ret0, ret1 = self.libSafe:call(self.workFunction, arg0, arg1)

--call a function of any other table:
local try, ret0, ret1 = self.libSafe:callTable(workTable, workTable.workFunction, arg0, arg1)

--or static (no eror logging):
local try, ret0, ret1 = LibSafe:callTable(workTable, workTable.workFunction, arg0, arg1)

--call a tableless function:
local try, ret0, ret1 = self.libSafe:callFn(workFunction, arg0, arg1)

--or static (no eror logging):
local try, ret0, ret1 = LibSafe:callFn(workFunction, arg0, arg1)
watch errors
Code:
--watch errors
for k,errorStr in pairs(self.libSafe.savedVariables.errors) do
  d("error: "..tostring(errorStr))
end
1.008
- 3.2: Clockwork
1.007
- 3.1: Horns of the Reach
1.006
- automatically ensures that a table is not made safe more than 1 time
- shorter error output to console
1.005
- improvements with the help of sirinsidiator, silvereyes333, votan, Ayantir, Shinni, and Dolgubon
- error log is now limited too 100 entries per default
1.002
- 1 line table safe maker
1.001
- callFn for executing tableless function
1.000
- release
Archived Files (1)
File Name
Version
Size
Author
Date
1.007
4kB
dryzler.elder-geek.net
09/02/17 04:03 PM


There have been no comments posted to this file.
Be the first to add one.



Category Jump: