refactor error handler and request filters