Skip to content

Commit 2948672

Browse files
fix: More robust error handling (#150)
Co-authored-by: Mikhail Podtserkovskiy <[email protected]>
1 parent 045e9e7 commit 2948672

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

cmd/scip-go/main.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func main() {
100100
}
101101
}
102102

103-
func mainErr() error {
103+
func mainErr() (err error) {
104104
// The default formatting also prints the date, which is generally not needed.
105105
log.SetTimeFormat("15:04:05")
106106
log.SetStyles(func() *log.Styles {
@@ -113,7 +113,7 @@ func mainErr() error {
113113
return s
114114
}())
115115

116-
if err := parseArgs(os.Args[1:]); err != nil {
116+
if err = parseArgs(os.Args[1:]); err != nil {
117117
return err
118118
}
119119

@@ -235,10 +235,11 @@ func mainErr() error {
235235
defer func() {
236236
if r := recover(); r != nil {
237237
removeOutFileIfPresent()
238+
err = fmt.Errorf("panic during indexing: %v", r)
238239
}
239240
}()
240241

241-
if err := index.Index(writer, options); err != nil {
242+
if err = index.Index(writer, options); err != nil {
242243
removeOutFileIfPresent()
243244
return err
244245
}

internal/implementations/implementations.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,9 @@ func extractInterfacesAndConcreteTypes(pkgs loader.PackageLookup, symbols *looku
168168
continue
169169
}
170170

171-
if pkg == nil || pkg.TypesInfo == nil {
172-
panic(fmt.Sprintf("nill types info %s", pkg.Name))
171+
if pkg.TypesInfo == nil {
172+
log.Warn("No types for package", "path", pkg.PkgPath)
173+
continue
173174
}
174175

175176
pkgSymbols := symbols.GetPackage(pkg)

0 commit comments

Comments
 (0)