Odd one that I can't figure out ... got a try/catc...
# suitescript
d
Odd one that I can't figure out ... got a try/catch in a map reduce script (that's running for ~5 minutes) and I can't print the error from the catch
Copy code
log.error({
	title: "map",
	details: JSON.stringify({
		'errObj.id': errObj.id,
		'errObj.cause': errObj.cause,
		'errObj.type': errObj.type,
		'errObj.message': errObj.message,
		'typeof(errObj)': typeof(errObj)
	})
});
returns
Copy code
{
  "typeof(errObj)": "object"
}
p
log.error('Error on: ' + context.key, error)
the log module will always run its own stringify function, so there should be no need to do it like that.
d
yeah I tried logging it directly, I get
{}
same as if I try
JSON.stringify(errObj)
n
where is errObj being initialised , is it the object in the catch i.e. catch(errObj)? Have you tried logging out errors in the summarise section?
Copy code
summary.mapSummary.errors.iterator().each(function(code, message) {
    log.error({title:'Map Error : ' + code, details:message});
});
d
yeah it's the error object from a try catch
p
This works in SS 2.0 try running a basic script like this: try { console.log('console is not defined'); } catch (error) { log.error(context.key, error); } if that does not return an error message, there might be something wrong in the getInputData, and you can log that error in the summary
b
your logging suggests that the error is an empty object, or an object with no keys on the current object
you can try using Object.keys to see if there is anything on the object
you can also try Object.getOwnPropertyNames, which will include non-enumerable keys
2.1 used to throw something similar, so use 2.0 if you happen to be using 2.1
d
yeah I was using 2.1 ... thanks for the help 🙂
b
@Ashwin K. is generally interested in hearing about 2.1 related errors, so send him details about your script
👍 1