I am sending a message with special characters to the server, since server cannot handle special characters it is replying with
</style>
</head>
<body>
<div id="content">
<h1>An Error Was Encountered</h1>
<p>The URI you submitted has disallowed characters.</p> </div>
</body>
</html>
And my app is crashing by throwing exception in JSON parser
JSON_FAIL(JSON_TEXT("Not JSON!"));
throw std::invalid_argument(EMPTY_STRING2);
Is it possible to check whether the message is valid or not before sending request to server.So i can put alert “not valid message” to the user or any other way to parse the error message(“An Error Was Encountere”) and displaying alert before parsing.
Since it was throwing an exception… I just put the parse method in try block and in the catch block I displayed an alert.