The use of catch/throw was a really good call here. There's a lot of complexity to this code, and it would certainly nest even deeper without that.