Clear cache works, but show an error

I’m clearing cache of doctype in a callback function. It’s working fine, but, is showing a irritant message error in console:

callback: function(r){
        frappe.show_alert("Títulos Parciais gerados!");
        //Limpar cache do doctype Titulos
        doc = r.message;
        delete locals[doc.doctype][];

(r.message = an doctype object)

Suppose error:

desk.min.js?ver=1506021412.0:1472 Unable to handle success response
desk.min.js?ver=1506021412.0:1473 TypeError: Cannot convert undefined or null to object
    at Object.callback (eval at setup (form.min.js?ver=1506021412.0:2620), <anonymous>:1183:36)
    at Object.callback [as success_callback] (desk.min.js?ver=1506021412.0:1345)
    at _ (desk.min.js?ver=1506021412.0:1369)
    at Object.<anonymous> (desk.min.js?ver=1506021412.0:1469)
    at i (jquery.min.js:2)
    at Object.fireWith [as resolveWith] (jquery.min.js:2)
    at z (jquery.min.js:4)
    at XMLHttpRequest.<anonymous> (jquery.min.js:4)

Try console logging the value of r.message, it seems to not have a value (is undefined) and hence you cannot access its doctype and name properties of doc.

This has a value, how I said, it’s working!
console.log("r.message: ", r.message);