diff --git a/all_test.go b/all_test.go index dd8ae18..12a9830 100644 --- a/all_test.go +++ b/all_test.go @@ -23,7 +23,7 @@ var trivialXml = []byte(`abcdefg`) func (s *BasicSuite) TestRootText(c *C) { node, err := xmlpath.Parse(bytes.NewBuffer(trivialXml)) c.Assert(err, IsNil) - path := xmlpath.MustCompile("/") + path, _ := xmlpath.MustCompile("/") result, ok := path.String(node) c.Assert(ok, Equals, true) c.Assert(result, Equals, "abcdefg") diff --git a/path.go b/path.go index db38ed5..ec378e0 100644 --- a/path.go +++ b/path.go @@ -422,12 +422,12 @@ func (step *pathStep) match(node *Node) bool { // MustCompile returns the compiled path, and panics if // there are any errors. -func MustCompile(path string) *Path { +func MustCompile(path string) (*Path, error) { e, err := Compile(path) if err != nil { - panic(err) + return nil, err } - return e + return e, nil } // Compile returns the compiled path.