You may find command:retry is a bit too granular, try the on fail event.
Cypress.on('fail', (error, runnable) => {
debugger
// take a look at the parameters
console.log('error', error.message)
console.log('runnable', runnable)
// for example
let currentTest = runnable.ctx.currentTest
let title = runnable.title
throw error // throw error to have test still fail
})
About retries
The runnable object passed to the on('fail') event has a couple of properties giving useful info about the retries.
Say you set {retries: 2} on the the test, the fail event is called for every attempt that fails.
On the first & second run, runnable.final === false.
On the third and last attempt, runnable.final === true plus runnable.prevAttempts has an array of the previous two (failed) attempts.
I haven't checked out what you get if, say, the third attempt passes.