Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Help understanding a runtime error
Started by RedBeach Oct 16 2017 02:53 PM

- - - - -
No replies to this topic
got no value tonumber runtime error
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

RedBeach

[GLOBAL: userInfoPane.html]
RedBeach
  • Corona Geek

  • 1,132 posts
  • Corona SDK

Hi guys. I would like some help from the senior devs around to help me understand the following runtime error that happened on a Android device (running a Corona Enterprise app).

Runtime Error - errorEvent=[ errorMessage ]=bad argument #2 to 'tonumber' (number expected, got no value)
Runtime Error - errorEvent=[ name ]=unhandledError
Runtime Error - errorEvent=[ stackTrace ]=
stack traceback:
	[C]: in function 'tonumber'
	?: in function <?:32>
	[C]: in function 'gsub'
	?: in function 'hexToString'
	?: in function '?'
	?: in function 'authenticate'
	?: in function 'new'
	?: in function '?'
	?: in function 'listener'
	/Users/jenkins/slaveroot/workspace/Enterprise/OS/xcode-8.3/release/release/subrepos/timer/timer.lua:210: in function 'method'
	/Users/jenkins/slaveroot/workspace/Enterprise/OS/xcode-8.3/release/release/platform/resources/init.lua:221: in function </Users/jenkins/slaveroot/workspace/Enterprise/OS/xcode-8.3/release/release/platform/resources/init.lua:190>

The function that throw that error was:

function hexToString(hexString)
    local byteString = (hexString:gsub('..', function (cc)
        return string.char(tonumber(cc, 16))
    end))
    return byteString
end

As I marked in bold above, the #2 parameter of 'tonumber' is 16, so how could I get a runtime error saying that #2 parameter had 'no value'?

 

Also, I never saw the  "no value" before... I am used to see "xxxxx expected, got nil".  Is "no value" == "nil"?

 

Thank you.

 

 

 

 




[topic_controls]
[/topic_controls]