From 09744f38efe0dd5a065b7cd5b02d65090cb50496 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Wed, 6 Sep 2017 11:53:30 -0700 Subject: [PATCH] add a ReleaseCapacityTooBig variant to UserError --- src/codec/error.rs | 4 ++++ src/proto/streams/recv.rs | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/codec/error.rs b/src/codec/error.rs index 12105a4..bdd2621 100644 --- a/src/codec/error.rs +++ b/src/codec/error.rs @@ -37,6 +37,9 @@ pub enum UserError { /// The application attempted to initiate too many streams to remote. Rejected, + + /// The released capacity is larger than claimed capacity. + ReleaseCapacityTooBig, } // ===== impl RecvError ===== @@ -109,6 +112,7 @@ impl error::Error for UserError { UnexpectedFrameType => "unexpected frame type", PayloadTooBig => "payload too big", Rejected => "rejected", + ReleaseCapacityTooBig => "release capacity too big", } } } diff --git a/src/proto/streams/recv.rs b/src/proto/streams/recv.rs index d0c9772..252a182 100644 --- a/src/proto/streams/recv.rs +++ b/src/proto/streams/recv.rs @@ -215,9 +215,9 @@ impl Recv -> Result<(), UserError> { trace!("release_capacity; size={}", capacity); + if capacity > stream.in_flight_recv_data { - // TODO: Handle error - unimplemented!(); + return Err(UserError::ReleaseCapacityTooBig); } // Decrement in-flight data