mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 11:35:22 +09:00
Fixed no error log from Datastore:update
This commit is contained in:
@@ -522,7 +522,7 @@ function Datastore:increment(key, delta)
|
|||||||
return self:set(key, value + (delta or 1))
|
return self:set(key, value + (delta or 1))
|
||||||
end
|
end
|
||||||
|
|
||||||
local function update_error(err) error('An error ocurred in datastore update: '..trace(err), 2) end
|
local function update_error(err) log('An error ocurred in datastore update: '..trace(err)) end
|
||||||
--[[-- Use a function to update the value locally, will trigger on_update then on_save, save_to_disk and auto_save is required for on_save
|
--[[-- Use a function to update the value locally, will trigger on_update then on_save, save_to_disk and auto_save is required for on_save
|
||||||
@tparam any key The key that you want to apply the update to, must be a string unless a serializer is set
|
@tparam any key The key that you want to apply the update to, must be a string unless a serializer is set
|
||||||
@tparam function callback The function that will be used to update the value at this key
|
@tparam function callback The function that will be used to update the value at this key
|
||||||
@@ -539,7 +539,9 @@ function Datastore:update(key, callback)
|
|||||||
local value = self:raw_get(key)
|
local value = self:raw_get(key)
|
||||||
local old_value = copy(self:raw_get(key))
|
local old_value = copy(self:raw_get(key))
|
||||||
local success, new_value = xpcall(callback, update_error, key, value)
|
local success, new_value = xpcall(callback, update_error, key, value)
|
||||||
if success and new_value ~= nil then
|
if not success then
|
||||||
|
self:raw_set(key, old_value)
|
||||||
|
elseif new_value ~= nil then
|
||||||
self:set(key, new_value)
|
self:set(key, new_value)
|
||||||
else
|
else
|
||||||
self:raise_event('on_update', key, value, old_value)
|
self:raise_event('on_update', key, value, old_value)
|
||||||
|
|||||||
Reference in New Issue
Block a user