Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- codes = {}
- function addCode(code, message)
- codes[code] = {}
- codes[code]["message"] = message
- return
- end
- function lookupCode(code)
- if codes[code] then
- print("Error code "..code.." says: ")
- term.setTextColor(colors.red)
- print(codes[code]["message"])
- term.setTextColor(colors.white)
- else
- print("No such code. Please retry your lookup.")
- end
- return
- end
- function removeCode(code)
- codes[code] = nil
- return
- end
- function printError(code)
- print(codes[code]["messasge"])
- return
- end
- function parseError(func)
- local ok, err = pcall(func)
- if not ok then
- w, h = term.getSize()
- term.setBackgroundColor(colors.blue)
- term.clear()
- term.setTextColor(1)
- term.setCursorPos(math.floor(w-string.len("An error has occurred, causing a crash"))/2, 2)
- print("An error has occurred, causing a crash")
- term.setCursorPos(math.floor(w-string.len(err))/2,4)
- print(err)
- term.setBackgroundColor(colors.black)
- term.setCursorPos(1,h)
- term.clearLine(h)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment