Shortcuts — How to get type of selected record?

Please help to create shortcut, which can detect type of currently selected record.

It should detect one of the following: nothing, group or file.

Without error, if selected nothing.

If selected nothing, nothing have to be defined, and so on.

I am going to use this shortcut as reusable one — to call it from another shortcuts. (DRY — do not repeat yourself)

Some of my shortcuts need selected group, another ones need selected file. None of them need selected nothing. So, if a shortcut needs a selected file, and currently selected is nothing or group, I want to get message like “Select a file.”