[knot] use goto for error handling