Leonardo RC522 ..compiles but does not scan the card

I am using Arduino Leonardo with RFID reader and writer RC522. I used this library

I can compile the code and can upload for the
rfid/DumpInfo.ino at master · miguelbalboa/rfid · GitHub Example.

When I open the Serial Monitor I see this

Firmware Version: 0x92 = v2.0
Scan PICC to see UID, SAK, type, and data blocks…

But when I put the rfid card that came with the rc522 board, it does not scan it. I have spent over 20 hours looking into it and cant seem to find propblem. Can anyone help

When I put the debugger above return statements,

void loop() {
mfrc522.PICC_DumpToSerial(&(mfrc522.uid));
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent()) {
return;
}

// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial()) {
return;
}

// Dump debug info about the card; PICC_HaltA() is automatically called
mfrc522.PICC_DumpToSerial(&(mfrc522.uid));
}

I get this error

Card UID:
Card SAK: 00
PICC type: MIFARE Ultralight or Ultralight C
Page 0 1 2 3
MIFARE_Read() failed: Timeout in communication.

The example code is garbage. It really needs to be purged from the internet.

Returning from loop() because things didn't go your way is childish behavior that 5 year old's are expected to have outgrown.

Delete all the f**king !s and return statements. Deal with success, and print an error message on failure.

Thanks for the reply. However even if I get rid of the !s and returns, essentially it will do same if I put this at the top of the loop statement

mfrc522.PICC_DumpToSerial(&(mfrc522.uid));

Which I did and then I posted the error that I got. Now since I am very new (2nd day ) with arduino, I am not sure how to handle this. Looking for some help here

It does not make sense to dump the data from a uid that you haven't successfully read from a card. So, stop doing that.

void loop()
{
   if(mfrc522.PICC_IsNewCardPresent())
   {
      Serial.println("Card present");
      if(mfrc522.PICC_ReadCardSerial())
      {
         Serial.println("Card read");
         // More positive tests here
      }
      else
      {
         Serial.println("Card present but not read");
   }
   else
   {
      Serial.println("No card present...");
   }
}

When this code runs, you know a LOT more than "it didn't work".