In Google Sheets (as in Excel, etc.), if the user enters an incorrect input into the formula, the error code will be printed in the offending cell, and a small pop-up window provides more detailed information about the error. Therefore, if I enter '= SQRT (-1)', '#NUM!' is printed in the cell and a popup explains that the value must be equal to or greater than 0.
How can I reproduce this using a special feature in Google Sheets? Throwing an exception basically works. For example, if I catch an input value outside the limits, and then create a special exception, "#ERROR!" is printed in the offending cell (this is normal), and the accompanying line of exceptions is printed in the corresponding pop-up window (which is also fine). The problem is that the Google Apps Script engine also adds the corresponding source line that generated the exception to the exception message. Therefore, instead of a popup, just reading "The input value must be between 0.0 and 1.0", it will read "The input value should be between 0.0 and 1.0 (line 199)."
Is there a way to suppress printing a line number or overwrite a popup message? I want to be able to create custom errors and provide detailed error messages for my users. But I do not want to be confused with references to a line number that has nothing to do with them.
source
share