If you hit the SHOW RAW button in Web IDE when you see the error, you’ll find out that it is related to this line
if (!sd.begin(chipSelect, SPI_HALF_SPEED))
You should be able to use SPI_FULL_SPEED
instead, but if that produces communication errors you can use SD_SCK_HZ(4 * MHZ)
instead of SPI_HALF_SPEED
.