There’s usually a command in the Console window or another error before the Error 7 reset.
Please copy-paste the Error 7 and the previous dozen or so lines from the Console window into a reply here. This may be the best way to see what happened.
Some of the Laptop USB ports have a yellow color coded insert in them. Yellow is ‘always on’ for charging but i’ve found it useful for when laptops try to snooze. You can also adjust your screen-saver or power management settings to avoid this.