Skip to content

Commit

Permalink
fatal -> panic
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjit-bhat committed Jun 10, 2024
1 parent 358c5c8 commit b2a135d
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions rpc/compiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type compiler struct {
func (c *compiler) getStructs(src string) []types.Object {
abs, err := filepath.Abs(src)
if err != nil {
log.Fatal(err)
log.Panic(err)
}
dir := path.Dir(src)

Expand All @@ -38,10 +38,10 @@ func (c *compiler) getStructs(src string) []types.Object {
}
pkgs, err := packages.Load(cfg, "")
if err != nil {
log.Fatal(err)
log.Panic(err)
}
if len(pkgs) != 1 {
log.Fatal("pkg len not 1")
log.Panic("pkg len not 1")
}
pkg := pkgs[0]
c.pkg = pkg
Expand All @@ -55,7 +55,7 @@ func (c *compiler) getStructs(src string) []types.Object {
}
}
if file == nil {
log.Fatal("found no files matching src. does src end in .go?")
log.Panic("found no files matching src. does src end in .go?")
}
c.file = file

Expand All @@ -78,7 +78,7 @@ func (c *compiler) getStructs(src string) []types.Object {
}
o, ok := info.Defs[s.Name]
if !ok {
log.Fatalf("%s is not in defs map", s.Name)
log.Panicf("%s is not in defs map", s.Name)
}
_ = o.Type().Underlying().(*types.Struct)
sts = append(sts, o)
Expand Down Expand Up @@ -115,7 +115,7 @@ func (c *compiler) genFieldWrite(field *types.Var) ast.Stmt {
case *types.Slice:
basic := fTy.Elem().(*types.Basic)
if basic.Kind() != types.Byte {
log.Fatal("unsupported slice elem ty: ", basic.Name())
log.Panic("unsupported slice elem ty: ", basic.Name())
}
isFixed, _ := c.getFixedLen(field)
if isFixed {
Expand All @@ -142,10 +142,10 @@ func (c *compiler) genFieldWrite(field *types.Var) ast.Stmt {
Sel: &ast.Ident{Name: "WriteBool"},
}
default:
log.Fatal("unsupported type: ", fTy.Name())
log.Panic("unsupported type: ", fTy.Name())
}
default:
log.Fatal("unsupported type: ", fTy)
log.Panic("unsupported type: ", fTy)
}
call := &ast.CallExpr{
Fun: fun,
Expand Down Expand Up @@ -223,7 +223,7 @@ func (c *compiler) genFieldRead(field *types.Var) []ast.Stmt {
case *types.Slice:
basic := fTy.Elem().(*types.Basic)
if basic.Kind() != types.Byte {
log.Fatal("unsupported slice elem ty: ", basic.Name())
log.Panic("unsupported slice elem ty: ", basic.Name())
}
isFixed, length := c.getFixedLen(field)
if isFixed {
Expand Down Expand Up @@ -265,10 +265,10 @@ func (c *compiler) genFieldRead(field *types.Var) []ast.Stmt {
Args: []ast.Expr{&ast.Ident{Name: "b"}},
}
default:
log.Fatal("unsupported type: ", fTy.Name())
log.Panic("unsupported type: ", fTy.Name())
}
default:
log.Fatal("unsupported type: ", fTy)
log.Panic("unsupported type: ", fTy)
}
assign := &ast.AssignStmt{
Lhs: []ast.Expr{
Expand Down Expand Up @@ -435,7 +435,7 @@ func printGo(n any) []byte {
buf := new(bytes.Buffer)
err := format.Node(buf, fset, n)
if err != nil {
log.Fatal(err)
log.Panic(err)
}
return buf.Bytes()
}
Expand All @@ -445,7 +445,7 @@ func printAst(src []byte) []byte {
fset := token.NewFileSet()
f, err := parser.ParseFile(fset, "", src, parser.ParseComments|parser.SkipObjectResolution)
if err != nil {
log.Fatal(err)
log.Panic(err)
}
res := new(bytes.Buffer)
ast.Fprint(res, fset, f, ast.NotNilFilter)
Expand Down

0 comments on commit b2a135d

Please sign in to comment.