The rest of this function assumes the object is an error and unconditionally sets .stack. (This only happens when debugging is enabled, but that doesn't relate to what object is passed in from my analysis of the code).