Guest User

Untitled

a guest
Jan 24th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. var thrift = require('thrift');
  2.  
  3. var test = require('./gen-nodejs/test.js'),
  4. ttypes = require('./gen-nodejs/test_types');
  5.  
  6. var server = thrift.createServer(test, {
  7. foo: function(bar,response) {
  8. console.log('Got: '+bar);
  9. if (bar == 1) {
  10. console.log('throw MyException');
  11. response(new ttypes.MyException({code: 0x0211, message: 'Test exception'}));
  12. } else if (bar == 2) {
  13. console.log('throw MyOtherException');
  14. response(new ttypes.MyOtherException({message: 'Test exception'}));
  15. } else {
  16. console.log('okay');
  17. response(null, 1234);
  18. }
  19. }
  20. });
  21.  
  22. server.listen(9090);
Add Comment
Please, Sign In to add comment