Closed terwanerik closed 5 years ago
NSError
actually does conform to Error
according to the swift docs. But that doesn't mean that every Error
is a NSError
, basically that's what the compiler is complaining about. But yeah the type cast should work then, right?
Since identifier
and reason
are in the protocol, not a protocol extension, it should use the implemented methods by the custom errors, not those of NSError
, right?
That's very strange. It seems almost like let downcast: Error = DebuggableTest.foo
is converting the error to an NSError
. I wonder if this happens on Linux.
Maybe instead of conforming NSError
to debuggable, we need to add special NSError
cases anywhere we print out errors (ErrorMiddleware, Log error, etc). @MrLotU any ideas?
Also, which Swift version are you on @terwanerik? I wonder if this happens with latest Swift 5.
Yeah really strange indeed.. Also happening on Linux/Docker, found the problem because the CI stopped working on Docker (clean install every time).
Running on Swift 4.2.1!
@tanner0101 For now, I think we should revert the NSError conformance to Debuggable, since it's breaking and get a "better" solution in place for Vapor 4, and than we can really think about how we want to do that (adding extra cases or smth)
The latest 3.6.0 release breaks type casting, xcode mentions that a forced cast from
Error
toDebuggable
always succeeds. I use this quite a bit in my unit tests, but i also noticed that theLogger
also notices this, saying that the case is already handled, but i don't think it actually is.Happening on line 29
Looks like conforming
NSError
toDebuggable
causes incorrect type casting. A quick test;Is there somewhere where
Error
actually conforms toNSError
? Since Xcode/Swift notices that the downcast always succeeds.It doesn't actually creates a
DebuggableTest
but just uses the identifier getter from the NSError extension.Is there another way to cast i should use?