RaiseOnError() with RapaGUI on Latest Android Player

Discuss GUI programming with the RapaGUI plugin here
Post Reply
PEB
Posts: 556
Joined: Sun Feb 21, 2010 1:28 am

RaiseOnError() with RapaGUI on Latest Android Player

Post by PEB »

Here's the code that shows the error:

Code: Select all

@REQUIRE "RapaGUI"

Function p_ErrorHandler(ErrCode, ErrStr$, ErrCmd, ErrLine)
	SystemRequest("Debug Output", "Code: "..ErrCode.."\nString: "..ErrStr$.."\nCommand: "..ErrCmd.."\nLine: "..ErrLine, "OK")
EndFunction

RaiseOnError(p_ErrorHandler)

Repeat
	WaitEvent
Forever
This is the error message that shows up:
Attempt to yield across metamethod/C-call boundary!
There also seems to be another error message behind it, but it disappears so fast that I can't read it.

amyren
Posts: 225
Joined: Thu May 02, 2019 11:53 am

Re: RaiseOnError() with RapaGUI on Latest Android Player

Post by amyren »

The message behind is:

Debug Output
Code: 1635
String: This error is for internal use only.
Command: WaitEvent
Line: 10

User avatar
airsoftsoftwair
Posts: 4764
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: RaiseOnError() with RapaGUI on Latest Android Player

Post by airsoftsoftwair »

Yes, this looks like a bug. Will be fixed.

User avatar
airsoftsoftwair
Posts: 4764
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: RaiseOnError() with RapaGUI on Latest Android Player

Post by airsoftsoftwair »

Fixed now.

PEB
Posts: 556
Joined: Sun Feb 21, 2010 1:28 am

Re: RaiseOnError() with RapaGUI on Latest Android Player

Post by PEB »

This error is still showing up with the latest Android Player.

Code: Select all

@REQUIRE "RapaGUI"

Function p_ErrorHandler(ErrCode, ErrStr$, ErrCmd, ErrLine)
	SystemRequest("Debug Output", "Code: "..ErrCode.."\nString: "..ErrStr$.."\nCommand: "..ErrCmd.."\nLine: "..ErrLine, "OK")
EndFunction

RaiseOnError(p_ErrorHandler)

LoadBrush(1, "DoesNotExist")

Repeat
	WaitEvent
Forever

User avatar
airsoftsoftwair
Posts: 4764
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: RaiseOnError() with RapaGUI on Latest Android Player

Post by airsoftsoftwair »

Hmm, the problem here is calling SystemRequest() in the error function. Functions that start a modal loop currently can't be used in the error function called by RaiseOnError() if RapaGUI is active. I'm not sure if this is easily fixable but I'll check.

PEB
Posts: 556
Joined: Sun Feb 21, 2010 1:28 am

Re: RaiseOnError() with RapaGUI on Latest Android Player

Post by PEB »

If it's a hard one to fix, this might be a good enough work-around:

Code: Select all

@REQUIRE "RapaGUI"

Function p_CustomErrorMessage(msg)
	SystemRequest("Debug Output", "Code: "..msg.userdata[0].."\nString: "..msg.userdata[1].."\nCommand: "..msg.userdata[2].."\nLine: "..msg.userdata[3], "OK")
EndFunction

Function p_ErrorHandler(ErrCode, ErrStr$, ErrCmd, ErrLine)
	SetTimeout(1, p_CustomErrorMessage, 500, {ErrCode, ErrStr$, ErrCmd, ErrLine})
EndFunction

RaiseOnError(p_ErrorHandler)

LoadBrush(1, "DoesNotExist")

Repeat
	WaitEvent
Forever

SamuraiCrow
Posts: 423
Joined: Fri May 15, 2015 5:15 pm
Location: Waterville, Minnesota USA

Re: RaiseOnError() with RapaGUI on Latest Android Player

Post by SamuraiCrow »

@PEB
If SystemRequest() is the problem, wouldn't moai.Request() be preferred?
I'm on registered MorphOS using FlowStudio.

User avatar
airsoftsoftwair
Posts: 4764
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: RaiseOnError() with RapaGUI on Latest Android Player

Post by airsoftsoftwair »

SamuraiCrow wrote:
Sun Jul 25, 2021 5:17 pm
@PEB
If SystemRequest() is the problem, wouldn't moai.Request() be preferred?
Won’t help because anything that starts a modal loop from within the error handler will trigger the error. PEB’s workaround is quite nice. An even better one would be to use RunCallback() instead of SetTimeout(). I haven’t tried it but it should work.

PEB
Posts: 556
Joined: Sun Feb 21, 2010 1:28 am

Re: RaiseOnError() with RapaGUI on Latest Android Player

Post by PEB »

Yes, RunCallback() does work and is better. Thanks for the suggestion!
(I keep forgetting to use that new function.) :oops:

Post Reply