Adds an error function.