Throwing Custom Exceptions And Error Messages In Google Sheets Custom Function?
In Google Sheets (as with Excel, etc) if a user enters bad input into a formula, an error code will be printed in the offending cell and a small pop-up provides more detail about t
Solution 1:
if (some_condition)
{
// will end execution with error
throw 'Error. My custom error description.';
}
Solution 2:
This is a reported problem.
Visit Issue 4422, star it to vote and for updates.
Solution 3:
Use try...catch
and the message property of the error object, then return the error message instead of throwing an error. I.E.:
/**
*
* @customfunction
*/
function myDiv(dividend,divisor){
var quotient;
try{
quotient = dividend / divisor;
} catch(error) {
quotient = error.message;
} finally {
return quotient;
}
}
Reference
Post a Comment for "Throwing Custom Exceptions And Error Messages In Google Sheets Custom Function?"