summaryrefslogtreecommitdiffstats
path: root/acf/error.lua
diff options
context:
space:
mode:
Diffstat (limited to 'acf/error.lua')
-rw-r--r--acf/error.lua23
1 files changed, 13 insertions, 10 deletions
diff --git a/acf/error.lua b/acf/error.lua
index 61788e5..7157d37 100644
--- a/acf/error.lua
+++ b/acf/error.lua
@@ -3,14 +3,14 @@ Copyright (c) 2012-2013 Kaarle Ritvanen
See LICENSE file for license details
--]]
-module(..., package.seeall)
+local M = {}
local object = require('acf.object')
local class = object.class
local util = require('acf.util')
-require 'json'
+local json = require('json')
local ErrorTable = class()
@@ -24,7 +24,7 @@ function ErrorTable:raise()
end
-ErrorList = class(ErrorTable)
+local ErrorList = class(ErrorTable)
function ErrorList:init(label)
object.super(self, ErrorList):init()
@@ -36,9 +36,9 @@ function ErrorList:insert(msg)
end
-ErrorDict = class(ErrorTable)
+M.ErrorDict = class(ErrorTable)
-function ErrorDict:collect(func, ...)
+function M.ErrorDict:collect(func, ...)
local function pack(success, ...)
local arg = {...}
return success, success and arg or arg[1]
@@ -68,14 +68,14 @@ function ErrorDict:collect(func, ...)
end
-function raise(label, msg)
+function M.raise(label, msg)
local err = ErrorList(label)
err:insert(msg)
err:raise()
end
-function relabel(label, ...)
- local err = ErrorDict()
+function M.relabel(label, ...)
+ local err = M.ErrorDict()
local res = {err:collect(...)}
if err:success() then return unpack(res) end
@@ -86,10 +86,13 @@ function relabel(label, ...)
elist:raise()
end
-function call(...)
- local err = ErrorDict()
+function M.call(...)
+ local err = M.ErrorDict()
local res = {err:collect(...)}
if err:success() then return true, unpack(res) end
if err.errors.system then error(err.errors.system[1]) end
return false, err.errors
end
+
+
+return M