]> git.tdb.fi Git - libs/core.git/commitdiff
Adjust exception messages
authorMikko Rasa <tdb@tdb.fi>
Tue, 6 Dec 2022 23:03:22 +0000 (01:03 +0200)
committerMikko Rasa <tdb@tdb.fi>
Tue, 6 Dec 2022 23:03:49 +0000 (01:03 +0200)
source/fs/windows/utils.cpp
source/io/poll.cpp
source/io/slice.cpp
source/io/unix/seekable.cpp
source/io/unix/serial.cpp
source/io/windows/handle.cpp
source/io/windows/seekable.cpp
source/io/windows/serial.cpp
source/stringcodec/codec.cpp

index 66699aaf0bc2229d3782116539e50213b90214d1..30a894394a9f6b97b0c064db8a5c5774867a63a8 100644 (file)
@@ -11,7 +11,7 @@ namespace FS {
 Path readlink(const Path &link)
 {
        (void)link;
-       throw unsupported("no symbolic links on win32");
+       throw unsupported("readlink");
 }
 
 Path realpath(const Path &path)
index cfaa57bde68f0265a5c8d50cde1dd8c78840616e..b23becdc0402710cae5d9978c8dca281e4ef1f5e 100644 (file)
@@ -44,7 +44,7 @@ void Poller::set_object(EventObject &obj, PollEvent ev)
 
 #ifdef _WIN32
        if(objects.size()>=MAXIMUM_WAIT_OBJECTS)
-               throw invalid_state("Maximum number of wait objects reached");
+               throw invalid_state("too many objects");
 #endif
 
        objects.push_back(PolledObject(&obj, ev));
@@ -91,7 +91,7 @@ PollEvent poll(EventObject &obj, PollEvent pe)
 PollEvent poll(EventObject &obj, PollEvent pe, const Time::TimeDelta &timeout)
 {
        if(timeout<Time::zero)
-               throw invalid_argument("poll");
+               throw invalid_argument("IO::poll");
 
        return platform_poll(obj, pe, static_cast<int>(timeout/Time::msec));
 }
index 98013b60c4e4c5c1c086e62d621c8224e2de522f..9ca5966c30acd1c03a18af313bbad5cc34737c81 100644 (file)
@@ -12,7 +12,7 @@ Slice::Slice(Seekable &b, SeekOffset s, SeekOffset l):
        length(l)
 {
        if(s<0 || l<0)
-               throw invalid_argument("Slice");
+               throw invalid_argument("Slice::Slice");
 
        Base::Synchronize sync(below);
        mode = below.get_mode()&M_RDWR;
index a402742a52338b7ba2d5f17cd639d6b37ca18c84..63af4b9646e7dace23ed2052b42d76293bbc8ffb 100644 (file)
@@ -21,7 +21,7 @@ int sys_seek_type(SeekType st)
        else if(st==S_END)
                return SEEK_END;
 
-       throw invalid_argument("sys_seek_type");
+       throw invalid_argument("IO::sys_seek");
 }
 
 }
index 70286b7ddd34294a98eea656704849501c681c85..728f3d884d92dfeb42411da62466769d19126c73 100644 (file)
@@ -80,14 +80,14 @@ void Serial::DeviceState::set_baud_rate(unsigned baud)
        case 3000000: speed = 0010015; break;
        case 3500000: speed = 0010016; break;
        case 4000000: speed = 0010017; break;
-       default: throw invalid_argument("set_baud_rate");
+       default: throw invalid_argument("Serial::set_baud_rate");
        }
 
        int ret = cfsetospeed(&state, speed);
        if(ret==0)
                ret = cfsetispeed(&state, speed);
        if(ret<0)
-               throw invalid_argument("set_baud_rate");
+               throw invalid_argument("Serial::set_baud_rate");
 }
 
 void Serial::DeviceState::set_data_bits(unsigned bits)
@@ -99,7 +99,7 @@ void Serial::DeviceState::set_data_bits(unsigned bits)
        case 6: flag = CS6; break;
        case 7: flag = CS7; break;
        case 8: flag = CS8; break;
-       default: throw invalid_argument("set_data_bits");
+       default: throw invalid_argument("Serial::set_data_bits");
        }
 
        state.c_cflag = (state.c_cflag&~CSIZE)|flag;
@@ -113,7 +113,7 @@ void Serial::DeviceState::set_parity(Serial::Parity par)
        case Serial::NONE: flag = 0; break;
        case Serial::EVEN: flag = PARENB; break;
        case Serial::ODD:  flag = PARENB|PARODD; break;
-       default: throw invalid_argument("set_parity");
+       default: throw invalid_argument("Serial::set_parity");
        }
 
        state.c_cflag = (state.c_cflag&~(PARENB|PARODD))|flag;
@@ -126,7 +126,7 @@ void Serial::DeviceState::set_stop_bits(unsigned bits)
        {
        case 1: flag = 0; break;
        case 2: flag = CSTOPB; break;
-       default: throw invalid_argument("set_stop_bits");
+       default: throw invalid_argument("Serial::set_stop_bits");
        }
 
        state.c_cflag = (state.c_cflag&~CSTOPB)|flag;
index 6d1219a24859e7757e9b1ba9e114ffbffa3793d7..e72282a4f98b0eaec2d8e5df50d3011850639e8f 100644 (file)
@@ -20,7 +20,7 @@ void sys_set_inherit(Handle &, bool)
 size_t sys_read(Handle &handle, char *buf, size_t size)
 {
        if(size>numeric_limits<DWORD>::max())
-               throw invalid_argument("read");
+               throw invalid_argument("IO::sys_read");
 
        DWORD ret;
        if(ReadFile(*handle, buf, size, &ret, nullptr)==0)
@@ -32,7 +32,7 @@ size_t sys_read(Handle &handle, char *buf, size_t size)
 size_t sys_write(Handle &handle, const char *buf, size_t size)
 {
        if(size>numeric_limits<DWORD>::max())
-               throw invalid_argument("write");
+               throw invalid_argument("IO::sys_write");
 
        DWORD ret;
        if(WriteFile(*handle, buf, size, &ret, nullptr)==0)
index 73c5cc51bc2824718bab9fb0af1591ddc0464b9b..c33a798fcf2c6c0eb71b44386b1bc2e43263c578 100644 (file)
@@ -19,7 +19,7 @@ int sys_seek_type(SeekType st)
        else if(st==S_END)
                return FILE_END;
 
-       throw invalid_argument("sys_seek_type");
+       throw invalid_argument("IO::sys_seek");
 }
 
 }
index bd086dd4d88e0985d6ab292f0bebeed92f5453f2..d041c8705ba3305105f7e806cbcdce98a1e20493 100644 (file)
@@ -56,7 +56,7 @@ void Serial::DeviceState::set_parity(Serial::Parity par)
        case Serial::NONE: state.Parity = NOPARITY; break;
        case Serial::EVEN: state.Parity = EVENPARITY; break;
        case Serial::ODD:  state.Parity = ODDPARITY; break;
-       default: throw invalid_argument("set_parity");
+       default: throw invalid_argument("Serial::set_parity");
        }
 }
 
@@ -66,7 +66,7 @@ void Serial::DeviceState::set_stop_bits(unsigned bits)
        {
        case 1: state.StopBits = ONESTOPBIT; break;
        case 2: state.StopBits = TWOSTOPBITS; break;
-       default: throw invalid_argument("set_stop_bits");
+       default: throw invalid_argument("Serial::set_stop_bits");
        }
 }
 
index abec134b1a0fd00a25f936952368beba22c62742..ff2bd63d5e657b8547392163d12aa50b94f40e13 100644 (file)
@@ -86,7 +86,7 @@ Codec *create_codec(const string &n)
                else if(em_str=="trans" || em_str=="transliterate")
                        em = TRANSLITERATE;
                else
-                       throw invalid_argument("invalid error mode");
+                       throw invalid_argument("StringCodec::create_codec");
        }
 
        if(name=="ascii") return new Ascii(em);
@@ -101,7 +101,7 @@ Codec *create_codec(const string &n)
        if(name=="utf16be") return new Utf16(em, Utf16::BIG);
        if(name=="utf16le") return new Utf16(em, Utf16::LITTLE);
        if(name=="windows1252" || name=="cp1252") return new Windows1252(em);
-       throw invalid_argument("unknown string codec");
+       throw invalid_argument("StringCodec::create_codec");
 }
 
 Codec *detect_codec(const string &str)