diff --git a/uppsrc/Core/BlockStream.cpp b/uppsrc/Core/BlockStream.cpp index 1b63e0210..fc5cd1bd5 100644 --- a/uppsrc/Core/BlockStream.cpp +++ b/uppsrc/Core/BlockStream.cpp @@ -334,7 +334,7 @@ bool FileStream::Open(const char *name, dword mode) { NULL ); if(handle == INVALID_HANDLE_VALUE) { - SetError(); + SetLastError(); return FALSE; } dword fsz_lo, fsz_hi; diff --git a/uppsrc/Core/Stream.cpp b/uppsrc/Core/Stream.cpp index 5b7e0ff2f..41064e4da 100644 --- a/uppsrc/Core/Stream.cpp +++ b/uppsrc/Core/Stream.cpp @@ -69,6 +69,11 @@ void Stream::LoadError() { throw LoadingError(); } +String Stream::GetErrorText() const +{ + return IsError() ? Upp::GetErrorMessage(errorcode) : String(); +} + bool Stream::GetAll(void *data, int size) { if(Get(data, size) != size) { LoadError(); diff --git a/uppsrc/Core/Stream.h b/uppsrc/Core/Stream.h index c5eaad8ee..01d43ce4e 100644 --- a/uppsrc/Core/Stream.h +++ b/uppsrc/Core/Stream.h @@ -71,6 +71,7 @@ public: void SetLastError() { SetError(errno); } #endif int GetError() const { return errorcode; } + String GetErrorText() const; void ClearError() { style = style & ~STRM_ERROR; errorcode = 0; } int64 GetPos() const { return dword(ptr - buffer) + pos; } diff --git a/uppsrc/Core/src.tpp/Stream$en-us.tpp b/uppsrc/Core/src.tpp/Stream$en-us.tpp index ae0b1a84c..f89cf174c 100644 --- a/uppsrc/Core/src.tpp/Stream$en-us.tpp +++ b/uppsrc/Core/src.tpp/Stream$en-us.tpp @@ -334,7 +334,12 @@ can be interpreted by GetErrorMessage function.&] [s4;%- &] [s5;:Stream`:`:GetError`(`)const:%- [@(0.0.255) int]_[* GetError]()_[@(0.0.255) const]&] [s2; Returns current error`-code. Zero indicates no error.&] -[s3; &] +[s3;%- &] +[s4;%- &] +[s5;:Upp`:`:Stream`:`:GetErrorText`(`)const:%- [_^Upp`:`:String^ String]_[* GetErrorText]( +)_[@(0.0.255) const]&] +[s2; Returns the text description of the last error.&] +[s3;%- &] [s4;%- &] [s5;:Stream`:`:ClearError`(`):%- [@(0.0.255) void]_[* ClearError]()&] [s2; Clears error code.&]