docs: function dumpException(ex)
  {
  	var ret;
  
  	if (!(ex instanceof Error))
  		throw (new Error(jsSprintf('invalid type for %%r: %j', ex)));
  
  	/* Note that V8 prepends "ex.stack" with ex.toString(). */
  	ret = 'EXCEPTION: ' + ex.constructor.name + ': ' + ex.stack;
  
  	if (ex.cause && typeof (ex.cause) === 'function') {
  		var cex = ex.cause();
  		if (cex) {
  			ret += '\nCaused by: ' + dumpException(cex);
  		}
  	}
  
  	return (ret);
  }