Skip to content

Commit d4c3a1f

Browse files
committed
fixup
1 parent 96215ec commit d4c3a1f

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

lib/internal/streams/body.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const {
4444
codes: {
4545
ERR_INVALID_ARG_TYPE,
4646
ERR_INVALID_RETURN_VALUE,
47+
ERR_INVALID_STATE,
4748
},
4849
} = require('internal/errors');
4950

@@ -213,8 +214,7 @@ class Body {
213214
const { readable } = this[kState];
214215

215216
if (readable === null) {
216-
// TODO: What error?
217-
throw new Error('readable consumed');
217+
throw new ERR_INVALID_STATE('Body is not readable');
218218
}
219219

220220
this[kState].readable = null;
@@ -226,8 +226,7 @@ class Body {
226226
const { writable } = this[kState];
227227

228228
if (writable === null) {
229-
// TODO: What error?
230-
throw new Error('writable consumed');
229+
throw new ERR_INVALID_STATE('Body is not writable');
231230
}
232231

233232
this[kState].writable = null;
@@ -237,13 +236,11 @@ class Body {
237236

238237
nodeStream() {
239238
if (this.readable === null) {
240-
// TODO: What error?
241-
throw new Error('readable consumed');
239+
throw new ERR_INVALID_STATE('Body is not readable');
242240
}
243241

244242
if (this.writable === null) {
245-
// TODO: What error?
246-
throw new Error('writable consumed');
243+
throw new ERR_INVALID_STATE('Body is not writable');
247244
}
248245

249246
if (this[kState].readable === this[kState].writable) {

0 commit comments

Comments
 (0)