diff --git a/src/eGLock.erl b/src/eGLock.erl index ecca3a6..f9df23c 100644 --- a/src/eGLock.erl +++ b/src/eGLock.erl @@ -124,13 +124,13 @@ lockApply(KeyOrKeys, MFAOrFun, TimeOut) -> true -> try doApply(MFAOrFun) catch C:R:S -> - {error, {lockApplyError, {C, R, S}}} + error({lockApplyError, KeyOrKeys, MFAOrFun, {C, R, S}}) after eNifLock:releaseLocks(KeyIxs), ok end; lockTimeout -> - {error, lockTimeout} + error({lockTimeout, KeyOrKeys, MFAOrFun}) end; _ -> KeyIx = erlang:phash2(KeyOrKeys, ?eGLockSize), @@ -138,13 +138,13 @@ lockApply(KeyOrKeys, MFAOrFun, TimeOut) -> true -> try doApply(MFAOrFun) catch C:R:S -> - {error, {lockApplyError, {KeyOrKeys, MFAOrFun}, {C, R, S}}} + error({lockApplyError, KeyOrKeys, MFAOrFun, {C, R, S}}) after eNifLock:releaseLock(KeyIx), ok end; lockTimeout -> - {error, lockTimeout} + error({lockTimeout, KeyOrKeys, MFAOrFun}) end end. @@ -170,13 +170,13 @@ lockGet({?undefTab, Key = GetKey}, TimeOut) -> try #{{?undefTab, GetKey} => undefined} catch C:R:S -> - {error, {lockGetError, {?undefTab, Key}, {C, R, S}}} + error({lockGetError, {?undefTab, Key}, {C, R, S}}) after eNifLock:releaseLock(KeyIx), ok end; lockTimeout -> - {error, lockTimeout} + error({lockTimeout, {?undefTab, Key}}) end; lockGet({EtsTab, Key} = GetKey, TimeOut) -> KeyIx = erlang:phash2(GetKey, ?eGLockSize), @@ -185,13 +185,13 @@ lockGet({EtsTab, Key} = GetKey, TimeOut) -> try #{GetKey => getEtsTabValue(EtsTab, Key, undefined)} catch C:R:S -> - {error, {lockGetError, GetKey, {C, R, S}}} + error({lockGetError, GetKey, {C, R, S}}) after eNifLock:releaseLock(KeyIx), ok end; lockTimeout -> - {error, lockTimeout} + error({lockTimeout, GetKey}) end; lockGet({?undefTab, Key = GetKey, DefValue}, TimeOut) -> KeyIx = erlang:phash2(GetKey, ?eGLockSize), @@ -200,13 +200,13 @@ lockGet({?undefTab, Key = GetKey, DefValue}, TimeOut) -> try #{{?undefTab, GetKey} => getDefValue(DefValue)} catch C:R:S -> - {error, {lockGetError, {?undefTab, Key, DefValue}, {C, R, S}}} + error({lockGetError, {?undefTab, Key, DefValue}, {C, R, S}}) after eNifLock:releaseLock(KeyIx), ok end; lockTimeout -> - {error, lockTimeout} + error({lockTimeout, {?undefTab, Key, DefValue}}) end; lockGet({EtsTab, Key, DefValue}, TimeOut) -> GetKey = {EtsTab, Key}, @@ -216,13 +216,13 @@ lockGet({EtsTab, Key, DefValue}, TimeOut) -> try #{GetKey => getEtsTabValue(EtsTab, Key, DefValue)} catch C:R:S -> - {error, {lockGetError, {EtsTab, Key, DefValue}, {C, R, S}}} + error({lockGetError, {EtsTab, Key, DefValue}, {C, R, S}}) after eNifLock:releaseLock(KeyIx), ok end; lockTimeout -> - {error, lockTimeout} + error({lockTimeout, {EtsTab, Key, DefValue}}) end; lockGet(EtsTabKeys, TimeOut) -> {KeyIxs, KeysMap} = getKeyIxAndMaps(EtsTabKeys, [], #{}), @@ -231,13 +231,13 @@ lockGet(EtsTabKeys, TimeOut) -> try #{OneGetKey => getEtsTabValue(OneEtsTab, OneKey, OneDefValue) || {OneEtsTab, OneKey} = OneGetKey := OneDefValue <- KeysMap} catch C:R:S -> - {error, {lockGetError, EtsTabKeys, {C, R, S}}} + error({lockGetError, EtsTabKeys, {C, R, S}}) after eNifLock:releaseLocks(KeyIxs), ok end; lockTimeout -> - {error, lockTimeout} + error({lockTimeout, EtsTabKeys}) end. getKeyIxAndMaps([], IxAcc, KeysMap) -> {IxAcc, KeysMap}; @@ -290,13 +290,13 @@ transaction(EtsTabKeys, MFAOrFun, TimeOut) -> catch throw:Throw -> Throw; C:R:S -> - {error, {lockTransactionError, {MFAOrFun, EtsTabKeys}, {C, R, S}}} + error({lockTransactionError, EtsTabKeys, MFAOrFun, {C, R, S}}) after eNifLock:releaseLocks(KeyIxs), ok end; lockTimeout -> - {error, lockTimeout} + error({lockTimeout, EtsTabKeys, MFAOrFun}) end. getDefValue(undefined) -> undefined;