Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat
"unhandledError" listener? - Gideros Forum

"unhandledError" listener?

Hey guys!
I watch recent video (in russian language) about mailgun.com error reporting from corona app. It's very primitive, yet pretty handy.
https://github.com/bogomazon/corona-mailgun

When unknown error occurs, app sends email via mailgun api, and player sees popup before app crushing.
image

How can we show this popup to user before app crush?
I see that in corona it's made using event.unhandledError, how can we detect such event in Gideros?
Thx!
local unhandledErrorListener = function( event )
    print( "We have a problem: " .. event.errorMessage )
end
 
Runtime:addEventListener( "unhandledError", unhandledErrorListener )
> Newcomers roadmap: from where to start learning Gideros
"What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
“The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
mailgun.jpg
698 x 426 - 73K

Comments

  • hgy29hgy29 Maintainer
    Accepted Answer
    Assuming we are dealing with lua errors, you can just wrap your code inside pcall() and handle errors from your code. Gideros does this too but don't send events. Maybe that can be added somehow to gideros.
    +1 -1 (+2 / -0 ) Share on Facebook
  • olegoleg Member
    edited April 5
    function f ()
      return "a" + 2  
    end -- f
     
    function err (x)
      print ("err called", x)
      return "oh no!"
    end -- err
     
    print (xpcall (f, err))
    ще варіант
    function myfunction(x, y)
    ...
      if ... then
        error("failed to do somthing")
      end
    ...
    end
     
    status, err = pcall(myfunction, x, y) -- f:функція, x-y: її аргументи
    if not status then
      -- опрацювати помилку err. в err знаходиться текст помилки "failed to do somthing"
    end

    Likes: Apollo14

    my games:
    https://play.google.com/store/apps/developer?id=razorback456
    мій блог по гідерос https://simartinfo.blogspot.com
    Слава Україні!
    +1 -1 (+1 / -0 ) Share on Facebook
  • Apollo14Apollo14 Member
    But we have lots of functions in our projects, it's sort of inconvenient to pcall every single one of them?

    Likes: keszegh

    > Newcomers roadmap: from where to start learning Gideros
    "What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
    “The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
    +1 -1 (+1 / -0 ) Share on Facebook
  • olegoleg Member
    Apollo14 said:

    But we have lots of functions in our projects, it's sort of inconvenient to pcall every single one of them?

    я всю гру беру в 1 фукцію
    my games:
    https://play.google.com/store/apps/developer?id=razorback456
    мій блог по гідерос https://simartinfo.blogspot.com
    Слава Україні!
Sign In or Register to comment.