Whenever creating a foreign key fails, the server reports something like
which is not very informative. One can get a much better understanding of an error by issuing SHOW ENGINE INNODB STATUS, if one knows to do it.
But one shouldn't be required to. The error information should be returned when an error happens. For example, InnoDB could return a warning with, say, "There is no index in the referenced table where the referenced columns appear as the first columns" (may be slightly paraphrased, as appropriate for a warning message).
It could still do its SHOW ENGINE INNODB STATUS, but returning a warning goes a long way towards helping users to understand the problem