Skip to content

Commit

Permalink
Merge pull request #8 from lambertjamesd/james-improve-error-messages
Browse files Browse the repository at this point in the history
Improve error messages
  • Loading branch information
trhodeos authored Oct 14, 2022
2 parents a67d290 + 42ae4e6 commit cc7ec9d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions cmd/spicy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ func main() {
as := spicy.NewRunner(*as_command)
objcopy := spicy.NewRunner(*objcopy_command)
preprocessed, err := spicy.PreprocessSpec(f, gcc, includeFlags, defineFlags, undefineFlags)

if err != nil {
panic(err)
}

spec, err := spicy.ParseSpec(preprocessed)
if err != nil {
panic(err)
Expand Down
6 changes: 5 additions & 1 deletion spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ func convertSegmentAst(s *SegmentAst) (*Segment, error) {
replaced := strings.Replace(statement.Value.String, "$(", "$", -1)
replaced = strings.Replace(replaced, ")", "", -1)
replaced = filepath.Clean(os.ExpandEnv(replaced))

seg.Includes = append(seg.Includes, replaced)
break
case "maxsize":
Expand Down Expand Up @@ -202,7 +203,10 @@ func convertWaveAst(s *WaveAst, segments map[string]*Segment) (*Wave, error) {
break
case "include":
seg := segments[statement.Value.String]
if seg.Flags.Object {

if seg == nil {
return nil, errors.New(fmt.Sprintf("Undefined segment '%s' included in wave", statement.Value.String));
} else if seg.Flags.Object {
out.ObjectSegments = append(out.ObjectSegments, seg)
} else if seg.Flags.Raw {
out.RawSegments = append(out.RawSegments, seg)
Expand Down

0 comments on commit cc7ec9d

Please sign in to comment.