def get(self, Size): app.logger.info('size is %d', Size) if Size <= 0: #checking for negative or 0 Size and responding with appropriate error message and status code app.logger.error('Invalid Size: Size must be a positive integer greater than 0 - status code 400') return Response.Build_Json_Response('Invalid Size: Size must be a positive integer greater than 0',400) elif Size >10000: # checking the max limit of size and responding with appropriate error message and status code app.logger.error('Size cannot be greater than 10000. Please pass a positive integer < 10000 - status code 400') return Response.Build_Json_Response('Size cannot be greater than 10000. Please pass a positive integer < 10000',400) else: #generating the fibonacci sequence if size is valid fib=str(GenerateFibonacci.Generate_Fibonacci(Size)) res=Response.Build_Json_Response(fib,200) app.logger.info("generated fibonacci sequence %s - status code %d" , fib,res.status_code ) return res
def handle_invalid_path(invalid_path): app.logger.info('size is %s', invalid_path) app.logger.error( 'Invalid Size: Size must be a positive integer greater than 0 - status code 400' ) return Response.Build_Json_Response( 'Invalid Size: Size must be a positive integer greater than 0', 400)
def Unhandled_Exceptions(e): app.logger.exception('exception generated - %s - status code 500', str(e)) return Response.Build_Json_Response(str(e), 500)
def method_not_allowed(e): app.logger.exception( 'exception generated - The method is not allowed for the requested URL. - status code 405' ) return Response.Build_Json_Response( 'The method is not allowed for the requested URL.', 405)
def page_not_found(e): app.logger.exception( 'exception generated - Page not found - status code 404') return Response.Build_Json_Response('Page not found', 404)