JSON decode with line and column error details
Crystal
require "json"
struct User
include JSON::Serializable
getter id : Int32
getter name : String
end
def parse_user(body : String) : User
User.from_json(body)
rescue ex : JSON::ParseException
raise ArgumentError.new("invalid JSON at #{ex.line_number}:#{ex.column_number}: #{ex.message}")
rescue ex : JSON::SerializableError
raise ArgumentError.new("invalid user shape: #{ex.message}")
end