[util] do not drop error in setenv
@@ -48,9 +48,18 @@ TString GetEnv(const TString& key, const TString& def) {
}
void SetEnv(const TString& key, const TString& value) {
+ bool isOk = false;
+ int errorCode = 0;
#ifdef _win_
- SetEnvironmentVariable(~key, ~value);
+ isOk = SetEnvironmentVariable(~key, ~value);
+ if (!isOk) {
+ errorCode = GetLastError();
+ }
#else
- setenv(~key, ~value, true /*replace*/);
+ isOk = (0 == setenv(~key, ~value, true /*replace*/));
+ if (!isOk) {
+ errorCode = errno;
+ }
#endif
+ Y_ENSURE_EX(isOk, TSystemError() << "failed to SetEnv with error-code " << errorCode);
}
