# Catch Warning message

**URL:** https://discourse.obspy.org/t/catch-warning-message/1186
**Category:** Development
**Created:** [February 22, 2021, 1:24pm UTC](https://discourse.obspy.org/t/catch-warning-message/1186 "2021-02-22T13:24:03Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Nikolaos\_Triantafyll](https://discourse.obspy.org/user_avatar/discourse.obspy.org/nikolaos_triantafyll/32/264_2.png) [@Nikolaos\_Triantafyll](https://discourse.obspy.org/u/Nikolaos_Triantafyll)
#### Post date: [February 22, 2021, 1:24pm UTC](https://discourse.obspy.org/t/catch-warning-message/1186/1 "2021-02-22T13:24:03Z")

</div>

Hi,  
How can I catch a warning message, for example:  
/usr/local/lib/python3.8/dist-packages/obspy/core/inventory/response.py:1895: UserWarning: More than one PolesZerosResponseStage encountered. Returning first one found.  
warnings.warn(msg)

I would actually like to overload the message with trace info such as station name.

Thank you

---

<div class="post-metadata">

### Author: ![trichter](https://discourse.obspy.org/user_avatar/discourse.obspy.org/trichter/32/226_2.png) [@trichter](https://discourse.obspy.org/u/trichter)
#### Post date: [February 22, 2021, 2:05pm UTC](https://discourse.obspy.org/t/catch-warning-message/1186/2 "2021-02-22T14:05:48Z")

</div>

Maybe the answer here is working for you: [https://stackoverflow.com/a/30368735](https://stackoverflow.com/a/30368735)

---

<div class="post-metadata">

### Author: ![Nikolaos\_Triantafyll](https://discourse.obspy.org/user_avatar/discourse.obspy.org/nikolaos_triantafyll/32/264_2.png) [@Nikolaos\_Triantafyll](https://discourse.obspy.org/u/Nikolaos_Triantafyll)
#### Post date: [February 22, 2021, 2:24pm UTC](https://discourse.obspy.org/t/catch-warning-message/1186/3 "2021-02-22T14:24:25Z")

</div>

The problem is that I would like the code to be able to continue after the warning (and as it already does). I just need to overload the message with more info.

---

<div class="post-metadata">

### Author: ![trichter](https://discourse.obspy.org/user_avatar/discourse.obspy.org/trichter/32/226_2.png) [@trichter](https://discourse.obspy.org/u/trichter)
#### Post date: [February 22, 2021, 3:43pm UTC](https://discourse.obspy.org/t/catch-warning-message/1186/4 "2021-02-22T15:43:13Z")

</div>

I see, then what about this one:  
[https://stackoverflow.com/questions/58213231/how-can-i-modify-python-warnings](https://stackoverflow.com/questions/58213231/how-can-i-modify-python-warnings)

---

<div class="post-metadata">

### Author: ![Nikolaos\_Triantafyll](https://discourse.obspy.org/user_avatar/discourse.obspy.org/nikolaos_triantafyll/32/264_2.png) [@Nikolaos\_Triantafyll](https://discourse.obspy.org/u/Nikolaos_Triantafyll)
#### Post date: [February 23, 2021, 6:06pm UTC](https://discourse.obspy.org/t/catch-warning-message/1186/5 "2021-02-23T18:06:28Z")

</div>

Yes, it worked! Thank you 🙂
