Skip to content

Commit

Permalink
Use idiomatic error messages
Browse files Browse the repository at this point in the history
- Avoid prepending "failed to..." or "error" to error messages.
- Fix typos.
  • Loading branch information
joshklop committed Aug 21, 2023
1 parent cf98453 commit b57de35
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions pkg/parsers/starknet/hint.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ func (i *InnerDoubleDeref) UnmarshalJSON(data []byte) error {

offset, ok := s[1].(float64)
if !ok {
return fmt.Errorf("failed to convert offset %v to float64", s[1])
return fmt.Errorf("convert offset %v to float64", s[1])
}
i.Offset = int(offset)

Expand All @@ -375,7 +375,7 @@ func (i *Immediate) UnmarshalJSON(data []byte) error {

immediate, ok := new(big.Int).SetString(str.Immediate, 0)
if !ok {
return fmt.Errorf("failed to convert immediate value %s to big.Int", str.Immediate)
return fmt.Errorf("convert immediate value %s to big.Int", str.Immediate)
}

i.Immediate = immediate
Expand Down
8 changes: 4 additions & 4 deletions pkg/parsers/starknet/program.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ func (b Builtin) MarshalJSON() ([]byte, error) {
return []byte("segment_arena"), nil

}
return nil, fmt.Errorf("error marshaling builtin with unknow identifer: %d", uint8(b))
return nil, fmt.Errorf("marshal unknown builtin: %d", uint8(b))
}

func (b *Builtin) UnmarshalJSON(data []byte) error {
builtinName, err := strconv.Unquote(string(data))
if err != nil {
return fmt.Errorf("error unmarsahling builtin: %w", err)
return fmt.Errorf("unmarshal builtin: %w", err)
}

switch builtinName {
Expand All @@ -74,7 +74,7 @@ func (b *Builtin) UnmarshalJSON(data []byte) error {
case "segment_arena":
*b = SegmentArena
default:
return fmt.Errorf("error unmarsahling unknwon builtin name: %s", builtinName)
return fmt.Errorf("unmarshal unknown builtin: %s", builtinName)
}
return nil
}
Expand Down Expand Up @@ -106,7 +106,7 @@ func (hints *Hints) UnmarshalJSON(data []byte) error {

index, ok := rawHints[0].(float64)
if !ok {
return fmt.Errorf("error unmarshaling hints: index should be uint64")
return fmt.Errorf("unmarshal hints: index should be uint64")
}
hints.Index = uint64(index)

Expand Down

0 comments on commit b57de35

Please sign in to comment.