Stream::GetErrorText

git-svn-id: svn://ultimatepp.org/upp/trunk@10201 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2016-09-06 15:35:06 +00:00
parent 7901d120fd
commit 33238140d3
4 changed files with 13 additions and 2 deletions

View file

@ -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;

View file

@ -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();

View file

@ -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; }

View file

@ -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.&]