Browse files

Inform user of error

  • Loading branch information...
1 parent 0412bd9 commit fb17415e9e9c692473693217804b4fe76999c62e @nikhilm committed Dec 14, 2010
Showing with 10 additions and 4 deletions.
  1. +10 −4 server.js
View
14 server.js
@@ -15,21 +15,27 @@ function getOut(code, error, resp) {
error = undefined;
}
- resp.writeHead(code);
+ resp.writeHead(code, { 'Content-Type': 'application/json' });
resp.end(JSON.stringify({
status: 'error',
message: error || 'Unknown error'
}));
}
function reply(faces, id, resp) {
- resp.writeHead(200, { 'Content-Type': 'application/json' });
- resp.end(JSON.stringify({
+ if( typeof(faces) == 'string' ) {
+ getOut(415, faces == 'No Error' ? 'Unknown error' : faces, resp);
+ return;
+ }
+
+ var obj = {
status: 'success',
faces: faces,
image_url: 'http://localhost:5000/image/'+id,
share_url: 'http://localhost:5000/view/'+id
- }));
+ };
+ resp.writeHead(200, { 'Content-Type': 'application/json' });
+ resp.end(JSON.stringify(obj));
}
function addToRedis(path, callback) {

0 comments on commit fb17415

Please sign in to comment.