Skip to content

Commit a78088e

Browse files
authored
report deserialization errors in more detail (#3675)
Report when serialization errors occur in more detail to help debug/fix rare bug if it occurs again.
1 parent 3eaad82 commit a78088e

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

errors/v2.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,3 +1353,8 @@
13531353
name: KorifiError
13541354
http_code: 500
13551355
message: "%s"
1356+
1357+
420001:
1358+
name: DeserializationError
1359+
http_code: 500
1360+
message: "%s"

lib/cloud_controller/serializer.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ def serializes_via_json(accessor_method_name)
77
string = send("#{accessor_method_name}_without_serialization")
88
return if string.blank?
99

10-
MultiJson.load string
10+
begin
11+
MultiJson.load string
12+
rescue MultiJson::ParseError
13+
error = "Failed to deserialize #{guid} for object type #{self.class}. Trying to deserialize #{string}. You may have to delete and recreate the object"
14+
raise CloudController::Errors::ApiError.new_from_details('DeserializationError', error)
15+
end
1116
end
1217
alias_method "#{accessor_method_name}_without_serialization", accessor_method_name
1318
alias_method accessor_method_name, "#{accessor_method_name}_with_serialization"

0 commit comments

Comments
 (0)