Update CreateWindow to capture and report errors correctly