Instructive message when a module is disabled accidentally Site breaks without a warning when code of a non-enabled module is called.
(In my project I disabled accidentally a module, while the code is executed by another module.)

The correct way is to add dependencies, but sometimes that is forgotten (and rather old-fashioned). PHP Storm does not check whether a module is active or not; it just validates the call.

Is there a way to get a message when code of a non-enabled module is called?
Absolutely. In the module that calls the function, use one of the following

Drupal 7:

if (module_exists('foo')) { 
  // Use a function provided by the module
}
else {
  drupal_set_message('Something is wrong');
}


Drupal 8:

$moduleHandler = \Drupal::service('module_handler');
if ($moduleHandler-&gt;moduleExists('foo')){
  // Use function provided by the module
}
else {
  drupal_set_message('Something is wrong');
}


If your code runs in a context that can use DI, inject the module handler service rather than getting it from \Drupal.

You're right, though, dependencies should be used and then this extra wrapping code isn't necessary. 

Dependency management is definitely not "old fashioned", by any stretch of the imagination; not in Drupal, and not in the greater world of programming/frameworks. It's a thriving, constantly-improving area of work.

I'm not sure where you got that idea from, but if that's what's stopping you using the proper methods to solve your problem, you should probably think about reevaluating your opinion, as (and no offence meant by this), it's quite frankly just wrong at the moment.