showErrors function

bool showErrors()

True when APP_ENV is development or local. Then error text may be sent to the client. Dox uses this rule for its own error answers. Use it when your code sends errors itself, so it follows the same rule.

String message = showErrors() ? '$error' : 'Server Error';

Implementation

bool showErrors() {
  String env = Env.get<String>('APP_ENV');
  if (!identical(env, _shownFor)) {
    String lower = env.toLowerCase();
    _show = lower == 'development' || lower == 'local';
    _shownFor = env;
  }
  return _show;
}