How to debug Server Syntax Error

Game development with Board Game Arena Studio
Post Reply
User avatar
GoDodyGo
Posts: 42
Joined: 14 August 2020, 07:30

How to debug Server Syntax Error

Post by GoDodyGo »

How can I debug why this message is appearing in the playing-player's JS console but I think is really coming from the PHP side?

Code: Select all

Server syntax error: tutorialrumone/tutorialrumone/playCard.html SyntaxError: Unexpected token '<' / <br />
<b>Notice</b>:  Array to string conversion in <b>/var/tournoi/release/tournoi-200922-0852-gs/www/game/utility/trace.game.php</b> on line <b>479</b><br />
<br />
<b>Notice</b>:  Array to string conversion in <b>/var/tournoi/release/tournoi-200922-0852-gs/www/game/utility/trace.game.php</b> on line <b>479</b><br />
<br />
<b>Notice</b>:  Array to string conversion in <b>/var/tournoi/release/tournoi-200922-0852-gs/www/game/utility/trace.game.php</b> on line <b>479</b><br />
{"status":1,"data":{"valid":1,"data":null}}
I am not allowed access to the source code for the referenced file:

Code: Select all

trace.game.php
So, I cannot see what's on line 479. Clicking PRETTY PRINT in the JS shows many very obscure references so I don't know how to follow it.

The error does not appear in the server side logs, BUT: the server log shows a 2nd identical playCard weblink being called after the first one, which it shouldn't do. This is that link:

Code: Select all

https://studio.boardgamearena.com/1/tutorialrumone/tutorialrumone/playCard.html?card_id=24&player_id=2333742&boardArea=playerDown_B&boardPlayer=2333743&lock=b40e04c4-7ec3-4935-8f02-db0be438d7ab&table=198904&testuser=2333742&dojo.preventCache=1601501712503

I cannot figure out why it's being called a 2nd time. The 1st call made the cards move and the other players saw the cards move and the SQL DB is correct.

BACKSTORY:
I'm implementing a card game where cards can be played from a player's hand, or swapped with jokers, or discarded, etc... (a rummy game). I've learned a lot but this is my first game implementation. Much of it works (you can draw cards, discard cards...)

(My game is called "tutorialrumone". I do have a function called "playCard", among many others.)

The thing is, the cards play properly but still the message appears.

Any advice on what I'm doing wrong? Thanks in advance!
User avatar
Victoria_La
Posts: 665
Joined: 28 December 2015, 20:55

Re: How to debug Server Syntax Error

Post by Victoria_La »

General rules on how to debug server are here: http://en.doc.boardgamearena.com/Practi ... my_view.29

Second client can happen if action is not locked.

I could not find project on the list of project because it does not have valid bgg id and therefore not listed (to look at code)
User avatar
GoDodyGo
Posts: 42
Joined: 14 August 2020, 07:30

Re: How to debug Server Syntax Error

Post by GoDodyGo »

Thanks for the quick reply. I have added a link to BGG (I think I did it right?). Does that let you see the code? If yes, then sorry for my messy code. I've got a LOT of console.log and self::dump lines in the files.

If not, then can I somehow invite you? I'm not sure how to share it.

I checked all my ajax calls do have lock:true (but does it matter if it's first or last in the list of parameters?).
User avatar
Victoria_La
Posts: 665
Joined: 28 December 2015, 20:55

Re: How to debug Server Syntax Error

Post by Victoria_La »

So basically it its logging code that trigger the error it trying to read string and its getting array, it can be in notification call.
Check you passing right param to all notification calls and call ${var} resolve as strings
Did you actually have this problem if you remove all your tracing calls?
User avatar
GoDodyGo
Posts: 42
Joined: 14 August 2020, 07:30

Re: How to debug Server Syntax Error

Post by GoDodyGo »

(not sure where my other reply went)

So I think that was it (the logging code)! Thanks for the help!! That error has gone away.

I removed a bunch of the self::trace() commands I had. Previously I had done self::trace($card_id) or similar. This works if the thing in the () is a string. However as you noted it doesn't work when it's an array. It throws that error. For that I have changed to use self::dump("message", $array_of_cards).
Post Reply

Return to “Developers”