Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
how to catch exception,error in Gideros — Gideros Forum

how to catch exception,error in Gideros

louislouis Member
edited September 2012 in General questions
I try to use pcall(function()end) and assertion(fucntion() end) in lua code, but program still crashed.
my question is how to catch exception in app ,if has I catch error,app can still work,not print stack trace on console and app crashed.
Tagged:

Comments

  • atilimatilim Maintainer
    Accepted Answer
    I think you need to give more information. For example here is a simple example code snippet:
    local function crash()
    	a[1] = 10
    end
     
    local status, err = pcall(crash)
     
    print(status, err)
    btw, does your program crash or give lua error?
  • sorry ,my fault.
    local function crash()
    	assert(nil,"crash error")
    end
     
    local status, err = pcall(crash)
     
    print(status, err)
  • @louis,
    I think the whole idea of assert is to crash if the condition was not met, assert cannot be masked even if used with pcall.
    twitter: @ozapps | http://www.oz-apps.com | http://howto.oz-apps.com | http://reviewme.oz-apps.com
    Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
    Cool Vizify Profile at https://www.vizify.com/oz-apps
Sign In or Register to comment.