Skip to content

Instantly share code, notes, and snippets.

@azat-co azat-co/gist:67509d5c8e38d2f5f4dd Secret
Last active Aug 29, 2015

Embed
What would you like to do?
var sendHipChatMessage = function(message, callback) {
var fromhost = server
.set('hostname')
.replace('-','')
.substr(0, 15); //truncate the string
try {
message = JSON.stringify(message);
} catch(e) {}
var data = {
'format': 'json',
auth_token: server.config.keys.hipchat.servers,
room_id: server.config.keys.hipchat.serversRoomId,
from: fromhost,
message: 'v'
+ server.set('version')
+ '\nmessage: '
+ message
};
request({
url:'http://api.hipchat.com/v1/rooms/message',
method:'POST',
qs: data}, function (e, r, body) {
if (e) console.error(e);
if (callback) return callback();
});
};
 
server.notify = {};
server.notify.error = function(e) {
var message = e.stack || e.message || e.name || e;
sendHipChatMessage(message);
console.error(message);
server.sendgrid.email({
to: 'error@webapplog.com',
from: server.set('hostname') + '@webapplog.com',
subject: 'Webapp '
+ server.set('version')
+ ' error: "'
+ e.name
+ '"',
category: 'webapp-error',
text: e.stack || e.message
}, exit);
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.