error generate in standalone mode
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
		
							
								
								
									
										8
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								main.go
									
									
									
									
									
								
							@@ -90,6 +90,9 @@ func (g *Generator) Generate(plugin *protogen.Plugin) error {
 | 
				
			|||||||
			continue
 | 
								continue
 | 
				
			||||||
		case "micro":
 | 
							case "micro":
 | 
				
			||||||
			err = g.microGenerate(component, plugin, genClient, genServer)
 | 
								err = g.microGenerate(component, plugin, genClient, genServer)
 | 
				
			||||||
 | 
								if err == nil {
 | 
				
			||||||
 | 
									err = g.writeErrors(plugin)
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
		case "http":
 | 
							case "http":
 | 
				
			||||||
			err = g.httpGenerate(component, plugin, genClient, genServer)
 | 
								err = g.httpGenerate(component, plugin, genClient, genServer)
 | 
				
			||||||
		case "grpc", "drpc", "rpc":
 | 
							case "grpc", "drpc", "rpc":
 | 
				
			||||||
@@ -113,11 +116,6 @@ func (g *Generator) Generate(plugin *protogen.Plugin) error {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if err = g.writeErrors(plugin); err != nil {
 | 
					 | 
				
			||||||
		plugin.Error(err)
 | 
					 | 
				
			||||||
		return err
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if err = g.astGenerate(plugin); err != nil {
 | 
						if err = g.astGenerate(plugin); err != nil {
 | 
				
			||||||
		plugin.Error(err)
 | 
							plugin.Error(err)
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										11
									
								
								util.go
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								util.go
									
									
									
									
									
								
							@@ -975,8 +975,10 @@ func (g *Generator) writeErrors(plugin *protogen.Plugin) error {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var gfile *protogen.GeneratedFile
 | 
						var gfile *protogen.GeneratedFile
 | 
				
			||||||
 | 
						var importPath protogen.GoImportPath
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if len(errorsMap) > 0 {
 | 
						if len(errorsMap) > 0 {
 | 
				
			||||||
		gfile = plugin.NewGeneratedFile("micro_errors.pb.go", ".")
 | 
					
 | 
				
			||||||
		var packageName string
 | 
							var packageName string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		for _, file := range plugin.Files {
 | 
							for _, file := range plugin.Files {
 | 
				
			||||||
@@ -987,9 +989,16 @@ func (g *Generator) writeErrors(plugin *protogen.Plugin) error {
 | 
				
			|||||||
				continue
 | 
									continue
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			packageName = string(file.GoPackageName)
 | 
								packageName = string(file.GoPackageName)
 | 
				
			||||||
 | 
								importPath = file.GoImportPath
 | 
				
			||||||
			break
 | 
								break
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if g.standalone {
 | 
				
			||||||
 | 
								importPath = "."
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							gfile = plugin.NewGeneratedFile("micro_errors.pb.go", importPath)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		gfile.P("// Code generated by protoc-gen-go-micro. DO NOT EDIT.")
 | 
							gfile.P("// Code generated by protoc-gen-go-micro. DO NOT EDIT.")
 | 
				
			||||||
		gfile.P("// protoc-gen-go-micro version: " + versionComment)
 | 
							gfile.P("// protoc-gen-go-micro version: " + versionComment)
 | 
				
			||||||
		gfile.P()
 | 
							gfile.P()
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user