Add exception handling to depth formatting