mirror of https://github.com/grpc/grpc-node.git
Make error messages match core
This commit is contained in:
parent
413dcd764b
commit
38ebfc8760
|
@ -44,7 +44,7 @@ export class MaxMessageSizeFilter extends BaseFilter implements Filter {
|
||||||
} else {
|
} else {
|
||||||
const concreteMessage = await message;
|
const concreteMessage = await message;
|
||||||
if (concreteMessage.message.length > this.maxSendMessageSize) {
|
if (concreteMessage.message.length > this.maxSendMessageSize) {
|
||||||
this.callStream.cancelWithStatus(Status.RESOURCE_EXHAUSTED, `Failed to send message of size ${concreteMessage.message.length} > max size ${this.maxSendMessageSize}`);
|
this.callStream.cancelWithStatus(Status.RESOURCE_EXHAUSTED, `Sent message larger than max (${concreteMessage.message.length} vs. ${this.maxSendMessageSize})`);
|
||||||
return Promise.reject<WriteObject>('Message too large');
|
return Promise.reject<WriteObject>('Message too large');
|
||||||
} else {
|
} else {
|
||||||
return concreteMessage;
|
return concreteMessage;
|
||||||
|
@ -60,7 +60,7 @@ export class MaxMessageSizeFilter extends BaseFilter implements Filter {
|
||||||
} else {
|
} else {
|
||||||
const concreteMessage = await message;
|
const concreteMessage = await message;
|
||||||
if (concreteMessage.length > this.maxReceiveMessageSize) {
|
if (concreteMessage.length > this.maxReceiveMessageSize) {
|
||||||
this.callStream.cancelWithStatus(Status.RESOURCE_EXHAUSTED, `Received message of size ${concreteMessage.length} > max size ${this.maxReceiveMessageSize}`);
|
this.callStream.cancelWithStatus(Status.RESOURCE_EXHAUSTED, `Received message larger than max (${concreteMessage.length} vs. ${this.maxReceiveMessageSize})`);
|
||||||
return Promise.reject<Buffer>('Message too large');
|
return Promise.reject<Buffer>('Message too large');
|
||||||
} else {
|
} else {
|
||||||
return concreteMessage;
|
return concreteMessage;
|
||||||
|
|
|
@ -449,7 +449,7 @@ export class Http2ServerCallStream<
|
||||||
if (this.maxReceiveMessageSize !== -1 && requestBytes.length > this.maxReceiveMessageSize) {
|
if (this.maxReceiveMessageSize !== -1 && requestBytes.length > this.maxReceiveMessageSize) {
|
||||||
this.sendError({
|
this.sendError({
|
||||||
code: Status.RESOURCE_EXHAUSTED,
|
code: Status.RESOURCE_EXHAUSTED,
|
||||||
details: `Server received message of size ${requestBytes.length} > max size ${this.maxReceiveMessageSize}`
|
details: `Received message larger than max (${requestBytes.length} vs. ${this.maxReceiveMessageSize})`
|
||||||
});
|
});
|
||||||
resolve();
|
resolve();
|
||||||
}
|
}
|
||||||
|
@ -576,7 +576,7 @@ export class Http2ServerCallStream<
|
||||||
if (this.maxSendMessageSize !== -1 && chunk.length > this.maxSendMessageSize) {
|
if (this.maxSendMessageSize !== -1 && chunk.length > this.maxSendMessageSize) {
|
||||||
this.sendError({
|
this.sendError({
|
||||||
code: Status.RESOURCE_EXHAUSTED,
|
code: Status.RESOURCE_EXHAUSTED,
|
||||||
details: `Server failed to send message of size ${chunk.length} > max size ${this.maxSendMessageSize}`
|
details: `Sent message larger than max (${chunk.length} vs. ${this.maxSendMessageSize})`
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -610,7 +610,7 @@ export class Http2ServerCallStream<
|
||||||
if (this.maxReceiveMessageSize !== -1 && message.length > this.maxReceiveMessageSize) {
|
if (this.maxReceiveMessageSize !== -1 && message.length > this.maxReceiveMessageSize) {
|
||||||
this.sendError({
|
this.sendError({
|
||||||
code: Status.RESOURCE_EXHAUSTED,
|
code: Status.RESOURCE_EXHAUSTED,
|
||||||
details: `Server received message of size ${message.length} > max size ${this.maxReceiveMessageSize}`
|
details: `Received message larger than max (${message.length} vs. ${this.maxReceiveMessageSize})`
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue