mirror of
https://github.com/ent/ent.git
synced 2026-04-28 05:30:56 +03:00
entc: catch build errors raised by the go importer (#1138)
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user