Skip to content

Commit

Permalink
Remove redundant error returns for unions
Browse files Browse the repository at this point in the history
  • Loading branch information
2opremio committed Nov 12, 2021
1 parent 7a45c67 commit b6f99ee
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/xdrgen/generators/go.rb
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,9 @@ def render_union_decode_from_interface(out, union)
out2.puts " return n, nil"
out2.string
end
out.puts " return n, fmt.Errorf(\"#{name(union.discriminant)} (#{reference union.discriminant.type}) switch value '%d' is not valid for union #{name}\", u.#{name(union.discriminant)})"
unless union.default_arm.present?
out.puts " return n, fmt.Errorf(\"#{name(union.discriminant)} (#{reference union.discriminant.type}) switch value '%d' is not valid for union #{name}\", u.#{name(union.discriminant)})"
end
out.puts "}"
out.break
end
Expand Down

0 comments on commit b6f99ee

Please sign in to comment.