Skip to content

Commit

Permalink
Fix Errorf
Browse files Browse the repository at this point in the history
  • Loading branch information
watal authored and Motok1 committed Nov 4, 2022
1 parent 5ebc73d commit 92958c1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions cmd/pola/sr_policy_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func newSrPolicyAddCmd() *cobra.Command {

noLinkStateFlag, err := cmd.Flags().GetBool("no-link-state")
if err != nil {
return fmt.Errorf("flag error\n")
return fmt.Errorf("flag error")

}

Expand All @@ -33,17 +33,17 @@ func newSrPolicyAddCmd() *cobra.Command {
return err
}
if filepath == "" {
return fmt.Errorf("File path option \"-f filepath\" is mandatory\n")
return fmt.Errorf("file path option \"-f filepath\" is mandatory")

}
f, openErr := os.Open(filepath)
if openErr != nil {
return fmt.Errorf("File \"%s\" can't open\n", filepath)
return fmt.Errorf("file \"%s\" can't open", filepath)
}
defer f.Close()
InputData := InputFormat{}
if err := yaml.NewDecoder(f).Decode(&InputData); err != nil {
return fmt.Errorf("File \"%s\" can't open\n", filepath)
return fmt.Errorf("file \"%s\" can't open", filepath)

}
if err := addSrPolicy(InputData, jsonFmt, noLinkStateFlag); err != nil {
Expand Down Expand Up @@ -192,11 +192,11 @@ func addSrPolicy(input InputFormat, jsonFlag bool, noLinkStateFlag bool) error {
case "te":
metric = pb.MetricType_TE
default:
return fmt.Errorf("invalid input `metric`\n")
return fmt.Errorf("invalid input `metric`")
}

default:
return fmt.Errorf("invalid input `type`\n")
return fmt.Errorf("invalid input `type`")
}

srPolicy := &pb.SrPolicy{
Expand All @@ -214,7 +214,7 @@ func addSrPolicy(input InputFormat, jsonFlag bool, noLinkStateFlag bool) error {
Asn: input.Asn,
}
if err := createSrPolicy(client, inputData); err != nil {
return fmt.Errorf("gRPC Server Error: %s\n", err.Error())
return fmt.Errorf("gRPC Server Error: %s", err.Error())

}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/packet/pcep/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ func (m *OpenMessage) DecodeFromBytes(byteOpenObj []uint8) error {
commonObjectHeader.DecodeFromBytes(byteOpenObj)

if commonObjectHeader.ObjectClass != OC_OPEN {
return fmt.Errorf("Unsupported ObjectClass: %d", commonObjectHeader.ObjectClass)
return fmt.Errorf("unsupported ObjectClass: %d", commonObjectHeader.ObjectClass)
}
if commonObjectHeader.ObjectType != 1 {
return fmt.Errorf("Unsupported ObjectType: %d", commonObjectHeader.ObjectType)
return fmt.Errorf("unsupported ObjectType: %d", commonObjectHeader.ObjectType)
}

var openObject OpenObject
Expand Down
2 changes: 1 addition & 1 deletion pkg/server/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (s *Session) ReceiveOpen() error {
return fmt.Errorf("PCEP version mismatch (receive version: %d)", openHeader.Version)
}
if openHeader.MessageType != pcep.MT_OPEN {
return fmt.Errorf("This peer has not been opened (messageType: %d)", openHeader.MessageType)
return fmt.Errorf("this peer has not been opened (messageType: %d)", openHeader.MessageType)
}

s.logger.Info("Receive Open", zap.String("session", s.peerAddr.String()))
Expand Down

0 comments on commit 92958c1

Please sign in to comment.