fix: renamed generator template to use ErrNotFound instead of NotFoundError
This commit is contained in:
+3
-3
@@ -95,7 +95,7 @@ func (c *Client) get{{ .StructName }}(ctx context.Context, site{{ if not .IsSett
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, NotFoundError
|
||||
return nil, ErrNotFound
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -123,7 +123,7 @@ func (c *Client) create{{ .StructName }}(ctx context.Context, site string, d *{{
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, NotFoundError
|
||||
return nil, ErrNotFound
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
@@ -148,7 +148,7 @@ func (c *Client) update{{ .StructName }}(ctx context.Context, site string, d *{{
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, NotFoundError
|
||||
return nil, ErrNotFound
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
@@ -368,7 +368,6 @@ func generateCode(fieldsDir string, outDir string) error {
|
||||
urlPath := strings.ToLower(name)
|
||||
structName := cleanName(name, fileReps)
|
||||
|
||||
goFile := strcase.ToSnake(structName) + ".generated.go"
|
||||
fieldsFilePath := filepath.Join(fieldsDir, fieldsFile.Name())
|
||||
b, err := os.ReadFile(fieldsFilePath)
|
||||
if err != nil {
|
||||
@@ -504,9 +503,10 @@ func generateCode(fieldsDir string, outDir string) error {
|
||||
continue
|
||||
}
|
||||
|
||||
goFile := strcase.ToSnake(structName) + ".generated.go"
|
||||
goFilePath := filepath.Join(outDir, goFile)
|
||||
_ = os.Remove(goFilePath)
|
||||
if err := os.WriteFile(goFile, ([]byte)(code), 0o644); err != nil {
|
||||
if err := os.WriteFile(goFilePath, ([]byte)(code), 0o644); err != nil {
|
||||
log.Errorf("failed to write file %s: %s", goFile, err)
|
||||
continue
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user