You'll encounter the "ReferenceError: window is not defined" error when you try to access the window object in an environment where it's not available.
In Swift you cannot rely on the compiler to check the error type for you, you have to use runtime checks or type casting to determine what kind of error you are dealing with.