lib/grape/error_formatter/json.rb in grape-1.6.2 vs lib/grape/error_formatter/json.rb in grape-1.7.0
- old
+ new
@@ -19,11 +19,17 @@
def wrap_message(message)
if message.is_a?(Exceptions::ValidationErrors) || message.is_a?(Hash)
message
else
- { error: message }
+ { error: ensure_utf8(message) }
end
+ end
+
+ def ensure_utf8(message)
+ return message unless message.respond_to? :encode
+
+ message.encode('UTF-8', invalid: :replace, undef: :replace)
end
end
end
end
end