entc: catch build errors raised by the go importer (#1138)

This commit is contained in:
Ariel Mashraki
2021-01-06 09:54:18 +02:00
committed by GitHub
parent 5118e82422
commit 0118fc698f
2 changed files with 2 additions and 2 deletions

View File

@@ -182,7 +182,7 @@ func mayRecover(err error, schemaPath string, cfg *gen.Config) error {
if enabled, _ := cfg.FeatureEnabled(gen.FeatureSnapshot.Name); !enabled {
return err
}
if errors.As(err, &packages.Error{}) || !internal.IsBuildError(err) {
if !errors.As(err, &packages.Error{}) && !internal.IsBuildError(err) {
return err
}
// If the build error comes from the schema package.

View File

@@ -218,7 +218,7 @@ func IsBuildError(err error) bool {
if strings.HasPrefix(err.Error(), "entc/load: #") {
return true
}
for _, s := range []string{"syntax error", "previous declaration", "invalid character"} {
for _, s := range []string{"syntax error", "previous declaration", "invalid character", "could not import"} {
if strings.Contains(err.Error(), s) {
return true
}