Skip to content

Commit c1f954b

Browse files
charmanderbrianc
authored andcommitted
Remove unreachable branch in parseE (#2020)
The message is created with a fixed name. 56b7c41, released in pg 2.4.0, was when this became applicable and the type of a `notice` event’s argument changed to an Error.
1 parent b03a3bd commit c1f954b

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

Diff for: lib/connection.js

+8-16
Original file line numberDiff line numberDiff line change
@@ -594,27 +594,19 @@ Connection.prototype._readValue = function (buffer) {
594594
// parses error
595595
Connection.prototype.parseE = function (buffer, length) {
596596
var fields = {}
597-
var msg, item
598-
var input = new Message('error', length)
599597
var fieldType = this.readString(buffer, 1)
600598
while (fieldType !== '\0') {
601599
fields[fieldType] = this.parseCString(buffer)
602600
fieldType = this.readString(buffer, 1)
603601
}
604-
if (input.name === 'error') {
605-
// the msg is an Error instance
606-
msg = new Error(fields.M)
607-
for (item in input) {
608-
// copy input properties to the error
609-
if (Object.prototype.hasOwnProperty.call(input, item)) {
610-
msg[item] = input[item]
611-
}
612-
}
613-
} else {
614-
// the msg is an object literal
615-
msg = input
616-
msg.message = fields.M
617-
}
602+
603+
// the msg is an Error instance
604+
var msg = new Error(fields.M)
605+
606+
// for compatibility with Message
607+
msg.name = 'error'
608+
msg.length = length
609+
618610
msg.severity = fields.S
619611
msg.code = fields.C
620612
msg.detail = fields.D

0 commit comments

Comments
 (0)