Skip to content

Remove unreachable branch in parseE #2020

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 12, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 8 additions & 16 deletions lib/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -594,27 +594,19 @@ Connection.prototype._readValue = function (buffer) {
// parses error
Connection.prototype.parseE = function (buffer, length) {
var fields = {}
var msg, item
var input = new Message('error', length)
var fieldType = this.readString(buffer, 1)
while (fieldType !== '\0') {
fields[fieldType] = this.parseCString(buffer)
fieldType = this.readString(buffer, 1)
}
if (input.name === 'error') {
// the msg is an Error instance
msg = new Error(fields.M)
for (item in input) {
// copy input properties to the error
if (Object.prototype.hasOwnProperty.call(input, item)) {
msg[item] = input[item]
}
}
} else {
// the msg is an object literal
msg = input
msg.message = fields.M
}

// the msg is an Error instance
var msg = new Error(fields.M)

// for compatibility with Message
msg.name = 'error'
msg.length = length

msg.severity = fields.S
msg.code = fields.C
msg.detail = fields.D
Expand Down