Skip to content

Commit

Permalink
optimize: change enum range check from error to warning
Browse files Browse the repository at this point in the history
  • Loading branch information
HeyJavaBean committed May 31, 2024
1 parent 6600bc0 commit f169c7d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions semantic/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package semantic

import (
"fmt"
"log"
"math"

"github.com/cloudwego/thriftgo/parser"
Expand Down Expand Up @@ -116,8 +117,7 @@ func (c *checker) CheckEnums(t *parser.Thrift) (warns []string, err error) {
}
// check if enum value can be safely converted to int 32
if v.Value < math.MinInt32 || v.Value > math.MaxInt32 {
err = fmt.Errorf("the value of enum %s is %d, which exceeds the range of int32", v.Name, v.Value)
return
log.Printf("the value of enum %s is %d, which exceeds the range of int32. Please adjust its value to fit within the int32 range to avoid data errors during serialization!!!", v.Name, v.Value)
}
}
}
Expand Down

0 comments on commit f169c7d

Please sign in to comment.