At Power On Reset (POR) the IRC is the default clock source. Before switching to the XTAL oscillator, your code should wait for the PLL to lock with the XTAL before switching from the IRC.
Using a timer, wait for a defined period of time and if the PLL does not lock with the XTAL as the input clock source, switch the PLL clock source to the IRC.
During application code execution the WDT can be use to recover the device if the XTAL fails, resetting the device.
The startup code should check if the reset was due to the WDT timeout and if the XTAL will not lock, revert to the IRC. The Reset Source Identification Register (RSID) in the LPC17xx identifies the source of the reset.