Adding DuckDuckGo search HTTPError handling
Labels: name: area: agent, name: auto:bug

### System Info

Bumped into HTTPError when using DuckDuckGo search wrapper in an agent, currently using `langchain==0.0.336`. 

Here's the snippet of the traceback as below.
```
  File "/path/to/venv/lib/python3.10/site-packages/langchain/utilities/duckduckgo_search.py", line 64, in run
    snippets = self.get_snippets(query)
  File "/path/to/venv/lib/python3.10/site-packages/langchain/utilities/duckduckgo_search.py", line 55, in get_snippets
    for i, res in enumerate(results, 1):
  File "/path/to/venv/lib/python3.10/site-packages/duckduckgo_search/duckduckgo_search.py", line 96, in text
    for i, result in enumerate(results, start=1):
  File "/path/to/venv/lib/python3.10/site-packages/duckduckgo_search/duckduckgo_search.py", line 148, in _text_api
    resp = self._get_url("GET", "https://links.duckduckgo.com/d.js", params=payload)
  File "/path/to/venv/lib/python3.10/site-packages/duckduckgo_search/duckduckgo_search.py", line 55, in _get_url
    raise ex
  File "/path/to/venv/lib/python3.10/site-packages/duckduckgo_search/duckduckgo_search.py", line 48, in _get_url
    raise httpx._exceptions.HTTPError("")
httpx.HTTPError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/path/to/src/single_host.py", line 179, in <module>
    response = chain({"topic": "Why did Sam Altman got fired by OpenAI.", 
  File "/path/to/venv/lib/python3.10/site-packages/langchain/chains/base.py", line 310, in __call__
    raise e
  File "/path/to/venv/lib/python3.10/site-packages/langchain/chains/base.py", line 306, in __call__
    else self._call(inputs)
  File "/path/to/src/single_host.py", line 163, in _call
    script = script_chain.run({"topic": inputs["topic"], "focuses": inputs["focuses"], "keypoints": keypoints})
  File "/path/to/venv/lib/python3.10/site-packages/langchain/chains/base.py", line 505, in run
    return self(args[0], callbacks=callbacks, tags=tags, metadata=metadata)[
  File "/path/to/venv/lib/python3.10/site-packages/langchain/chains/base.py", line 310, in __call__
    raise e
  File "/path/to/venv/lib/python3.10/site-packages/langchain/chains/base.py", line 306, in __call__
    else self._call(inputs)
  File "/path/to/src/single_host.py", line 117, in _call
    information = agent.run(background_info_search_formatted)
  File "/path/to/venv/lib/python3.10/site-packages/langchain/chains/base.py", line 505, in run
    return self(args[0], callbacks=callbacks, tags=tags, metadata=metadata)[
  File "/path/to/venv/lib/python3.10/site-packages/langchain/chains/base.py", line 310, in __call__
    raise e
  File "/path/to/venv/lib/python3.10/site-packages/langchain/chains/base.py", line 304, in __call__
    self._call(inputs, run_manager=run_manager)
  File "/path/to/venv/lib/python3.10/site-packages/langchain/agents/agent.py", line 1245, in _call
    next_step_output = self._take_next_step(
  File "/path/to/venv/lib/python3.10/site-packages/langchain/agents/agent.py", line 1095, in _take_next_step
    observation = tool.run(
  File "/path/to/venv/lib/python3.10/site-packages/langchain/tools/base.py", line 344, in run
    raise e
  File "/path/to/venv/lib/python3.10/site-packages/langchain/tools/base.py", line 337, in run
    self._run(*tool_args, run_manager=run_manager, **tool_kwargs)
  File "/path/to/venv/lib/python3.10/site-packages/langchain/tools/base.py", line 510, in _run
    self.func(
  File "/path/to/venv/lib/python3.10/site-packages/langchain/tools/base.py", line 344, in run
    raise e
  File "/path/to/venv/lib/python3.10/site-packages/langchain/tools/base.py", line 337, in run
    self._run(*tool_args, run_manager=run_manager, **tool_kwargs)
  File "/path/to/venv/lib/python3.10/site-packages/langchain/tools/ddg_search/tool.py", line 36, in _run
    return self.api_wrapper.run(query)
  File "/path/to/venv/lib/python3.10/site-packages/langchain/utilities/duckduckgo_search.py", line 67, in run
    raise ToolException("DuckDuckGo Search encountered HTTPError.")
```

I tried to add an error handling in the method `run()` in `langchain/utilities/duckduckgo_search.py`, something look like below:

```
def run(self, query: str) -> str:
        try:
            snippets = self.get_snippets(query)
            return " ".join(snippets)
        except httpx._exceptions.HTTPError as e:
            raise ToolException("DuckDuckGo Search encountered HTTPError.")
```

I have also added `handle_tool_error`, where it was copied from the langchain [documentation](https://python.langchain.com/docs/modules/agents/tools/custom_tools)
```
def _handle_error(error: ToolException) -> str:
    return (
        "The following errors occurred during tool execution:"
        + error.args[0]
        + "Please try another tool."
    )
```

However these methods do not seems to stop and still cause the error showed in first code block above. Am I implementing this incorrectly? or should there be other mechanism to handle the error occuried? 

### Who can help?

_No response_

### Information

- [X] The official example notebooks/scripts
- [X] My own modified scripts

### Related Components

- [ ] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [X] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

1. Adding `handle_tool_errors` and passing the `_handle_error` function into it. 

```
news_tool = Tool.from_function(name="News Search", 
                   func=news_duckduckgo.run, 
                   description="News search to help you look up latest news, which help you to understand latest current affair, and being up-to-date.",
                   handle_tool_errors=_handle_error)
```
2. Does not seems to work, so I tried to change the DuckDuckGo Wrapper, as described above. 
3. HTTPError still lead to abrupt stop of Agent actions. 

### Expected behavior

Expecting a proper error handling method, if tool fails, Agent moves on, or try n time before moving on to next step.