Code stops while trying to read rfid

Hey guys, I am using the PN532 rfid reader and its corresponding adafruit library. What I want to do is to check the rfid reader for a card, read it if there is one and move on if there isnt. However, the examples all use this line of code to check the scanner:

success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);

And it seems this just waits untill theres an rfid card and does nothing else. I wanted to try using a try/catch block, but it seems those are disable in the arduino IDE.
Any tips on how I could accomplish this?

you can use the last parameter to set a timeout. the default is 0 that's why it's blocking.

  bool readPassiveTargetID(
      uint8_t cardbaudrate, uint8_t *uid, uint8_t *uidLength,
      uint16_t timeout = 0); // timeout 0 means no timeout - will block forever.

EDIT: seen you deleted your ask while I was researching the right answer and posting

Assume you found out. but would have been cool to keep the question for others with the same ask.

yeah I found an answer on a different forum with a slightly different search term, I figured since that one had an aswer it would be redundant to leave this open, but I dont mind leaving it un-deleted either. The answer I found was to add this line:

  nfc.setPassiveActivationRetries(0x9A);

Wich works and probably does about the same as your code.

Thanks for your answer!

That's another way indeed