swift-nio
swift-nio copied to clipboard
NIOLoopBound has bad error messages
NIOCore/NIOLoopBound.swift:47: Precondition failed
is all I get :|. I'd have expected some more information. Particularly:
- what was wrong (wrong thread, maybe even expected and actual thread names)
- which line was wrong (the bug is not in NIOLoopBound, it's in the code calling it)
preconditionInEventLoop
doesn't currently allow custom error messages, but we could at least pass the file-and-line upwards.
preconditionInEventLoop
doesn't currently allow custom error messages, but we could at least pass the file-and-line upwards.
Okay, file/line would help a lot! And I guess we should change the message in preconditionInEventLoop
from just Precondition failed
to Precondition failed: Not on expected EventLoop thread
or something along those lines.
And preconditionInEventLoop
could actually pop out expected: ..., actual: ...
thread names etc. If completely outside of an eventLoop thread we could say expected: SelectableEventLoop(foo, thread: NIO-ELT-#0-0), actual: <not an EventLoopThread>
We can do that in the case of MTELG, but it won't work on all ELGs.