Make error messages match core

This commit is contained in:
Michael Lumish 2020-04-09 16:15:33 -07:00
parent 413dcd764b
commit 38ebfc8760
2 changed files with 5 additions and 5 deletions

View File

@ -44,7 +44,7 @@ export class MaxMessageSizeFilter extends BaseFilter implements Filter {
} else {
const concreteMessage = await message;
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');
} else {
return concreteMessage;
@ -60,7 +60,7 @@ export class MaxMessageSizeFilter extends BaseFilter implements Filter {
} else {
const concreteMessage = await message;
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');
} else {
return concreteMessage;

View File

@ -449,7 +449,7 @@ export class Http2ServerCallStream<
if (this.maxReceiveMessageSize !== -1 && requestBytes.length > this.maxReceiveMessageSize) {
this.sendError({
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();
}
@ -576,7 +576,7 @@ export class Http2ServerCallStream<
if (this.maxSendMessageSize !== -1 && chunk.length > this.maxSendMessageSize) {
this.sendError({
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;
}
@ -610,7 +610,7 @@ export class Http2ServerCallStream<
if (this.maxReceiveMessageSize !== -1 && message.length > this.maxReceiveMessageSize) {
this.sendError({
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;
}