private void catchStoreExceptionAndVerifyErrorCode(StoreMethodCaller methodCaller) throws StoreException {
    properties.put("store.io.error.count.to.trigger.shutdown", "1");
    ReplicaStatusDelegate mockDelegate = mock(ReplicaStatusDelegate.class);
    storeMetrics = new StoreMetrics(new MetricRegistry());
    MockBlobStore mockBlobStore =
        new MockBlobStore(getMockReplicaId(tempDirStr), new StoreConfig(new VerifiableProperties(properties)),
            Collections.singletonList(mockDelegate), storeMetrics);
    // First, verify that a normal shutdown will create a clean shutdown file in the store directory.
    mockBlobStore.start();
    mockBlobStore.shutdown();
    File shutdownFile = new File(tempDir, PersistentIndex.CLEAN_SHUTDOWN_FILENAME);
    assertTrue("Clean shutdown file should exist", shutdownFile.exists());

    mockBlobStore.start();
    // Second, verify that store won't be shut down if Unknown_Error occurred.
    StoreException storeExceptionInIndex = new StoreException("Mock Unknown error", StoreErrorCodes.UnknownError);
    mockBlobStore.setPersistentIndex(storeExceptionInIndex);
    try {
      methodCaller.invoke(mockBlobStore);
      fail("should fail");
    } catch (StoreException e) {
      assertEquals("Mismatch in StoreErrorCode", StoreErrorCodes.UnknownError, e.getErrorCode());
    }
    assertTrue("Store should not be shut down", mockBlobStore.isStarted());
    assertEquals("Mismatch in store io error count", 0, mockBlobStore.getErrorCount().get());

    // Third, verify that store will be shut down if IOError occurred (disk I/O error)
    storeExceptionInIndex = new StoreException("Mock disk I/O error", StoreErrorCodes.IOError);
    mockBlobStore.setPersistentIndex(storeExceptionInIndex);
    try {
      methodCaller.invoke(mockBlobStore);
      fail("should fail");
    } catch (StoreException e) {
      assertEquals("Mismatch in StoreErrorCode", StoreErrorCodes.IOError, e.getErrorCode());
    }
    assertFalse("Store should be shutdown after error count exceeded threshold", mockBlobStore.isStarted());

    // In the end, verify that store shutdown would skip any disk flush operation if it is triggered by a real disk I/O error.
    assertFalse("When encountering disk I/O error, clean shutdown file shouldn't exist", shutdownFile.exists());
  }
Verify store method can capture store exception and correctly handle it. The method also verifies that if exception
is really caused by disk I/O error, store shutdown process would skip any disk flush operation and no clean shutdown
file should exist in directory.
@param methodCaller the method caller to invoke store methods to trigger store exception
@throws StoreException
ambry-store/src/test/java/com/github/ambry/store/BlobStoreTest.java