Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8360165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:22:34+00:00 2026-06-09T11:22:34+00:00

I am fairly new to google apps script and I came across this issue

  • 0

I am fairly new to google apps script and I came across this issue while trying out tutorial on “Your First Custom Function”.

=in2mm(1) -> 25.4
=in2mm(2) -> 50.8
=in2mm() -> #ERROR (error: input must be a number (line 6))
=in2mm(pi()) -> 79.7964534011807
=in2mm(a) -> #NAME? (error: Unknown range name a)
=in2mm(*) -> #ERROR (error: Parse error)

I am trying to understand the usage of “throw” function in google apps script. How is it able to produce the “input must be a number” in my line 3 whereas line 5 and 6 produces some other results?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T11:22:36+00:00Added an answer on June 9, 2026 at 11:22 am

    You could make the error message more explicit by adding some case handling like this :

    function in2mm(inNum) {
      // Function to convert from INCHES to MILLIMETERS
      var outNum = 0;     // this will hold the answer
      var factor = 25.4;  // multiply input by this factor to get output
        if (inNum == "") {  // check to make sure input is a number
        throw ("error: input must not be empty");  // throw an exception with the error message
        }else if (typeof inNum != "number") {  // check to make sure input is a number
        throw ("error: input must be a number (now it is a "+typeof inNum+")");  // throw an exception with the error message
    }
      outNum = inNum * factor;  // calculate the answer
      return outNum;  // return the answer to the cell which has the formula
    }
    

    But the argument has to be ‘valid’ to be handled by the function… in you example =in2mm(a) a is interpreted as a named region and since you don’t have a region called ‘a’ it thows an error before trying to execute the function. That’s why the error message doesn’t come from the function itself but from the ‘engine’ under the spreadsheet.

    The other example =in2mm(*) return a Parse error for the same reason, the argument is not valid and in this case it cannot be a range either… you could also try + or – , it will try to calculate something but it can’t and again the error message comes from the spreadsheet, not from your function.

    Try to use a valid range and change the values in the target cell, you’ll see completely different results. For example in A2 write =in2mm(A1) and play with A1

    Hoping I made things a (little) bit clearer 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am fairly new to OSX development, so this may be easy but google
I am fairly new to developing android apps. What I am trying to do
I'm fairly new to C++ and an trying to figure out to use the
I'm fairly experienced with Google Apps Script in Spreadsheets, and want to get going
First time poster and fairly new to ASP programming. I am trying to add
i'm fairly new to PHP and can't seem to figure this one out. i've
Fairly new to Objective C and trying to work within Storyboards given it's the
I fairly new to JQuery and perhaps trying to achieve something that might be
I'm fairly new to JQuery and Javascript in general. I don't think I'm trying
Fairly new to Google Maps API. I've got an array of data that I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.