what's your device model number?
have you checked if it's the cable's issue?? as you may know, the cables are very easy to damage, any damage or shorting (of a sort) along the cable will cause phone to reject and not support it.
Otherwise you can take the phone to UbreakIfix and have the phone diagnosed. Another option is to submit an issue report using Samsung Members app after you see that message again; screenshots or screen recordings sometimes help with the explanation of what's happening.