mirror of
https://github.com/apple/swift-nio-http2
synced 2026-11-24 04:38:00 +00:00
Add a location to each of 'NIOHTTP2Errors' (#247)
Motivation: Without knowing where an error was thrown it can be unnecessarily difficult to work out the reasons an application ended up in an error state. Modifications: - Add a 'file' string to each of the 'NIOHTTP2Errors' denoting the file and line where an error was created - Add static methods to create errors to 'NIOHTTP2Errors' defaulting file and line, this is unfortunately necessary as defaulting file and line in the `init` makes the defaulted and non-defaulted errors indistinguishable, and the compiler will pick the one with fewest defaulted values. - Add equatable conformance manually so as to ignore 'file' - Add backing storage to errors which no longer be stored in an existential container - Add 'CustomStringConvertible' conformance to the errors using backing storage so that the 'file' is actually visible when converting the error - Deprecate the old `init`s - Fix all deprecation warnings Result: - NIOHTTP2Errors carry a 'file' with them indicating where they were created
This commit is contained in:
1 parent
28d94c489d
commit
440d64d99a
33 files changed
+1598
-233
No files matched your search
@@ -87,14 +87,14 @@ struct HTTP2FlowControlWindow {
|
||||
assert(amount <= HTTP2FlowControlWindow.maxIncrement)
|
||||
|
||||
guard amount >= 1 else {
|
||||
throw NIOHTTP2Errors.InvalidWindowIncrementSize()
|
||||
throw NIOHTTP2Errors.invalidWindowIncrementSize()
|
||||
}
|
||||
|
||||
// We now need to bounds check to confirm that our window size will remain in the valid range. We use
|
||||
// subtraction to avoid integer overflow. Note that if the current window size is negative then all window
|
||||
// update increments are valid.
|
||||
guard (self.windowSize < 0) || (HTTP2FlowControlWindow.maxSize - self.windowSize >= amount) else {
|
||||
throw NIOHTTP2Errors.InvalidFlowControlWindowSize(delta: Int(amount), currentWindowSize: Int(self.windowSize))
|
||||
throw NIOHTTP2Errors.invalidFlowControlWindowSize(delta: Int(amount), currentWindowSize: Int(self.windowSize))
|
||||
}
|
||||
|
||||
self.windowSize += Int32(amount)
|
||||
@@ -116,7 +116,7 @@ struct HTTP2FlowControlWindow {
|
||||
assert(amount >= -(Int32.max))
|
||||
|
||||
guard (self.windowSize < 0) || (HTTP2FlowControlWindow.maxSize - self.windowSize >= amount) else {
|
||||
throw NIOHTTP2Errors.InvalidFlowControlWindowSize(delta: Int(amount), currentWindowSize: Int(self.windowSize))
|
||||
throw NIOHTTP2Errors.invalidFlowControlWindowSize(delta: Int(amount), currentWindowSize: Int(self.windowSize))
|
||||
}
|
||||
|
||||
self.windowSize += amount
|
||||
@@ -134,7 +134,7 @@ struct HTTP2FlowControlWindow {
|
||||
let size = Int32(size)
|
||||
|
||||
guard self.windowSize >= size else {
|
||||
throw NIOHTTP2Errors.FlowControlViolation()
|
||||
throw NIOHTTP2Errors.flowControlViolation()
|
||||
}
|
||||
|
||||
self.windowSize -= size
|
||||
|
||||
Reference in new issue
Block a user