swift-nio icon indicating copy to clipboard operation
swift-nio copied to clipboard

NIOLoopBound has bad error messages

Open weissi opened this issue 1 year ago • 4 comments

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)

weissi avatar Oct 23 '23 10:10 weissi

preconditionInEventLoop doesn't currently allow custom error messages, but we could at least pass the file-and-line upwards.

Lukasa avatar Oct 23 '23 11:10 Lukasa

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.

weissi avatar Oct 23 '23 11:10 weissi

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>

weissi avatar Oct 23 '23 11:10 weissi

We can do that in the case of MTELG, but it won't work on all ELGs.

Lukasa avatar Oct 23 '23 12:10 Lukasa