rorodata / firefly

function as a service
http://rorodata.github.io/firefly
Apache License 2.0
194 stars 30 forks source link

firefly server doesnt send the exception message raised from the firefly-function #52

Closed sohail535 closed 7 years ago

sohail535 commented 7 years ago

I'm running the firefly function with following contents of test.py

def hello_flok(greet):
    if greet == 'world':
        raise ValueError('hello world is very old, try hello flok instead')
    return 'hello '+greet+'!!'

when the function raises the exception it is not being communicated back to the client with the appropriate exception message

Traceback from firefly server.

firefly test.hello_flok
http://127.0.0.1:8000/
127.0.0.1 - - [11/Aug/2017 12:54:45] "GET / HTTP/1.1" 200 171
127.0.0.1 - - [11/Aug/2017 12:54:45] "POST /hello_flok HTTP/1.1" 200 16
127.0.0.1 - - [11/Aug/2017 12:54:53] "GET / HTTP/1.1" 200 171
Traceback (most recent call last):
  File "/usr/lib/python3.5/wsgiref/handlers.py", line 137, in run
    self.result = application(self.environ, self.start_response)
  File "/home/sohail/Envs/firefly-test/lib/python3.5/site-packages/firefly/app.py", line 42, in __call__
    response = self.process_request(request)
  File "/home/sohail/Envs/firefly-test/lib/python3.5/site-packages/firefly/app.py", line 66, in process_request
    response = func(request)
  File "/home/sohail/Envs/firefly-test/lib/python3.5/site-packages/firefly/app.py", line 96, in __call__
    result = self.function(**kwargs)
  File "/home/sohail/rorodata/firefly-test/test.py", line 3, in hello_flok
    raise ValueError('hello world is very old, try hello flok instead')
ValueError: hello world is very old, try hello flok instead
127.0.0.1 - - [11/Aug/2017 12:54:53] "POST /hello_flok HTTP/1.1" 500 59

Traceback from firefly-client.

>>> import firefly
>>> c = firefly.Client('http://127.0.0.1:8000')
>>> c.hello_flok(greet='myself')
'hello myself!!'
>>> c.hello_flok(greet='world')
Traceback (most recent call last):
  File "<input>", line 1, in <module>
    c.hello_flok(greet='world')
  File "/home/sohail/Envs/firefly-test/lib/python3.5/site-packages/firefly/client.py", line 60, in wrapped
    return client.call_func(func_name, **kwargs)
  File "/home/sohail/Envs/firefly-test/lib/python3.5/site-packages/firefly/client.py", line 26, in call_func
    return self.handle_response(response)
  File "/home/sohail/Envs/firefly-test/lib/python3.5/site-packages/firefly/client.py", line 54, in handle_response
    raise FireflyError("Internal Server Error")
firefly.client.FireflyError: Internal Server Error
>>> 

It would be good if the exception message is sent back to the client, instead of just saying Internal Server Error

palnabarun commented 7 years ago

Fixed in #53