Fix error output for module operations on types.

Replace the error messages (shown when a non-module type is used as a
module) with internal debug messages. This is in line with the nearby
error behavior.

Closes #10551.