Recently went through a similar issue with my 350. Pull the fuel pump out of the tank and ensure the fuel line isn't kinked, also change the fuel filter while you're in there.
There were also several cases of the bike shutting off in similar fashion that was related to the condenser but that was on pre '17 bikes.
Mine ended up being a bad spark plug and it never flashed a code.
It can be very difficult to troubleshoot because there's several things that have very similar symptoms. I talked to one of the KTM mechanics at Loretta's and he told me the most common cause is fuel issues. Mainly being the fuel like kink, fuel filters clogged, and even the fuel pump going out, also the fuel pump relay.
Also check the tip over sensor under your seat. Pull it out and shake it to ensure the piece inside is moving freely and that the sensor hasn't popped off the tabs and tilted.