try {
  // throw new LangException with located exception message:
  thow new LangException(
    'Exception message for developers', EXCEPTION_CODE, null,
    new LangText('LBL_TRANSLATABLE_USER_MESSAGE'));
} catch (LangException $e) {
  // using logger to inform the developer about the exception
  $log = LoggerManager::getLogger();
  $log->fatal('Exception happend in the example: ' . $e->getMessage() . ', code: ' . $e->getCode());
  // using SugarApplication to inform the user about the problem with translated message:
  SugarApplication::appendErrorMessage($e->getLangMessage());
}