From: Mikko Rasa Date: Tue, 6 Dec 2022 23:03:22 +0000 (+0200) Subject: Adjust exception messages X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=95a005d09584925e1d865caea57b9352c0770b00;p=libs%2Fcore.git Adjust exception messages --- diff --git a/source/fs/windows/utils.cpp b/source/fs/windows/utils.cpp index 66699aa..30a8943 100644 --- a/source/fs/windows/utils.cpp +++ b/source/fs/windows/utils.cpp @@ -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) diff --git a/source/io/poll.cpp b/source/io/poll.cpp index cfaa57b..b23becd 100644 --- a/source/io/poll.cpp +++ b/source/io/poll.cpp @@ -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(timeout/Time::msec)); } diff --git a/source/io/slice.cpp b/source/io/slice.cpp index 98013b6..9ca5966 100644 --- a/source/io/slice.cpp +++ b/source/io/slice.cpp @@ -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; diff --git a/source/io/unix/seekable.cpp b/source/io/unix/seekable.cpp index a402742..63af4b9 100644 --- a/source/io/unix/seekable.cpp +++ b/source/io/unix/seekable.cpp @@ -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"); } } diff --git a/source/io/unix/serial.cpp b/source/io/unix/serial.cpp index 70286b7..728f3d8 100644 --- a/source/io/unix/serial.cpp +++ b/source/io/unix/serial.cpp @@ -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; diff --git a/source/io/windows/handle.cpp b/source/io/windows/handle.cpp index 6d1219a..e72282a 100644 --- a/source/io/windows/handle.cpp +++ b/source/io/windows/handle.cpp @@ -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::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::max()) - throw invalid_argument("write"); + throw invalid_argument("IO::sys_write"); DWORD ret; if(WriteFile(*handle, buf, size, &ret, nullptr)==0) diff --git a/source/io/windows/seekable.cpp b/source/io/windows/seekable.cpp index 73c5cc5..c33a798 100644 --- a/source/io/windows/seekable.cpp +++ b/source/io/windows/seekable.cpp @@ -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"); } } diff --git a/source/io/windows/serial.cpp b/source/io/windows/serial.cpp index bd086dd..d041c87 100644 --- a/source/io/windows/serial.cpp +++ b/source/io/windows/serial.cpp @@ -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"); } } diff --git a/source/stringcodec/codec.cpp b/source/stringcodec/codec.cpp index abec134..ff2bd63 100644 --- a/source/stringcodec/codec.cpp +++ b/source/stringcodec/codec.cpp @@ -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)