adjust error handling

This commit is contained in:
filifa 2025-04-05 17:57:00 -04:00
parent c313758b2c
commit 9eae0d1a95
1 changed files with 5 additions and 5 deletions

View File

@ -22,6 +22,7 @@ import (
"go/ast"
"go/parser"
"go/token"
"log"
"os"
"path/filepath"
@ -106,7 +107,7 @@ func constructDependencyGraph(typesUsed map[filename][]typename, declaredAt map[
declFile, ok := declaredAt[t]
if !ok {
return nil, errors.New(string(t) + " not found")
return nil, errors.New("did not find declaration for " + string(t))
}
if fname == declFile {
@ -130,7 +131,7 @@ func parse(cmd *cobra.Command, args []string) {
fset := token.NewFileSet()
pkgs, err := parser.ParseDir(fset, pkg, nil, 0)
if err != nil {
panic(err)
log.Fatal(err)
}
typesUsed := make(map[filename][]typename)
@ -174,13 +175,12 @@ func parse(cmd *cobra.Command, args []string) {
depGraph, err := constructDependencyGraph(typesUsed, declaredAt, ignores)
if err != nil {
// TODO: handle this error better
panic(err)
log.Fatal(err)
}
viz, err := dot.Marshal(depGraph, "deps", "", "\t")
if err != nil {
panic(err)
log.Fatal(err)
}
fmt.Println(string(viz))