Skip to content

Commit

Permalink
Merge pull request #22 from yury-palyanitsa/resolution-early-return
Browse files Browse the repository at this point in the history
Add early return on resolution errors
  • Loading branch information
yury-palyanitsa authored Oct 7, 2024
2 parents 9c55764 + 786ecc5 commit d669895
Showing 1 changed file with 4 additions and 25 deletions.
29 changes: 4 additions & 25 deletions parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,54 +375,33 @@ func (r *RAML) parseFragment(f io.ReadSeeker, fragmentPath string, pOpts *parser
stacktrace.WithInfo("head", head), stacktrace.WithType(stacktrace.TypeParsing))
}

var st *stacktrace.StackTrace

err = r.resolveShapes()
if err != nil {
st = StacktraceNewWrapped("resolve shapes", err, fragmentPath,
return StacktraceNewWrapped("resolve shapes", err, fragmentPath,
stacktrace.WithType(stacktrace.TypeParsing))
}
err = r.resolveDomainExtensions()
if err != nil {
se := StacktraceNewWrapped("resolve domain extensions", err, fragmentPath,
return StacktraceNewWrapped("resolve domain extensions", err, fragmentPath,
stacktrace.WithType(stacktrace.TypeParsing))
if st == nil {
st = se
} else {
st = st.Append(se)
}
}

if pOpts.withUnwrapOpt {
err = r.UnwrapShapes()
if err != nil {
se := StacktraceNewWrapped("unwrap shapes", err, fragmentPath,
return StacktraceNewWrapped("unwrap shapes", err, fragmentPath,
stacktrace.WithType(stacktrace.TypeParsing))
if st == nil {
st = se
} else {
st = st.Append(se)
}
}
}

if pOpts.withValidateOpt {
err = r.ValidateShapes()
if err != nil {
se := StacktraceNewWrapped("validate shapes", err, fragmentPath,
return StacktraceNewWrapped("validate shapes", err, fragmentPath,
stacktrace.WithType(stacktrace.TypeParsing))
if st == nil {
st = se
} else {
st = st.Append(se)
}
}
}

if st != nil {
return st
}

return nil
}

Expand Down

0 comments on commit d669895

Please sign in to comment.