Mercurial > psgxs
changeset 40:741110cdcfcf
Avoid exposing unneeded object.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sun, 20 Feb 2011 14:32:49 +0100 |
parents | 4c808bfe0658 |
children | bc717575e66a |
files | errors.js |
diffstat | 1 files changed, 7 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/errors.js +++ b/errors.js @@ -176,42 +176,39 @@ errors.owner = { }, }; -errors.reverse = {}; +var reverse = {}; -function reverseError(o) { +(function reverseError(o) { for (var i in o) { if (i == 'reverse' || typeof (o[i]) == 'number'); else if (!o[i].n) reverseError(o[i]); else { var k = {}; - //var k = {name: i}; for (var j in o[i]) { if (j != 'n') k[j] = o[i][j]; } - errors.reverse[o[i].n] = k; + reverse[o[i].n] = k; } } -} - -reverseError(errors); +})(errors); exports.makeError = function(response, errorNumber, payload) { response.attr.type = 'error'; if (payload) response.cnode(payload); - var e = errors.reverse[errorNumber]; + var e = reverse[errorNumber]; response.c('error', {type: e.type}); response.c(e.error, {xmlns: 'urn:ietf:params:xml:ns:xmpp-stanzas'}).up(); if (e.reason) { if (e.feature) - response.c(e.reason, {xmlns: 'http://jabber.org/protocol/pubsub#errors', feature: e.feature}).up(); + response.c(e.reason, {xmlns: 'http://jabber.org/protocol/pubsub#errors', feature: e.feature}); else - response.c(e.reason, {xmlns: 'http://jabber.org/protocol/pubsub#errors'}).up(); + response.c(e.reason, {xmlns: 'http://jabber.org/protocol/pubsub#errors'}); } return response;