added a function which generates an error from an error code, including <err> and <append> tags