Complete the code to catch errors when connecting to Redis.
try { const client = redis.createClient(); await client.connect(); } catch ([1]) { console.error('Connection error:', [1]); }
The catch block receives the error object, commonly named err to handle connection errors.
Complete the code to listen for Redis client error events.
client.on('error', function([1]) { console.log('Redis error:', [1]); });
The error event handler receives an error object, commonly named err.
Fix the error in the code to properly handle Redis command errors.
client.get('key', function(err, reply) { if ([1]) { console.error('Command error:', err); return; } console.log('Value:', reply); });
Check if err exists to detect command errors before using the reply.
Fill both blanks to handle Redis connection errors and close the client.
client.on('error', function([1]) { console.error('Redis error:', [1]); client.[2](); });
The error event handler receives err. To close the client, call client.quit().
Fill all three blanks to retry connecting on error with a delay.
client.on('error', async function([1]) { console.error('Error:', [1]); await new Promise(resolve => setTimeout(resolve, [2])); await client.[3](); });
Use err as the error parameter, wait 1000 milliseconds, then call client.connect() to retry.
