# Exception Handling

**URL:** <https://discuss.elastic.co/t/exception-handling/38989>\
**Category:** Logstash\
**Created:** [January 12, 2016, 2:21pm UTC](https://discuss.elastic.co/t/exception-handling/38989 "2016-01-12T14:21:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![matteocremolini](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matteocremolini/32/7096_2.png) [@matteocremolini](https://discuss.elastic.co/u/matteocremolini)\
**Post date:** [January 12, 2016, 2:21pm UTC](https://discuss.elastic.co/t/exception-handling/38989/1 "2016-01-12T14:21:24Z")

</div>

Hi all !!!!

I'm using this filter:

date {  
match =\> ["My field","dd-MM-YYYY HH.mm.ss","ISO8601"]  
target =\> ["My field"]  
}

I would like handle the runtime exception that can occur.

For example a code structure like this:

try  
{  
// my filter  
}  
catch()  
{  
// exception handling ==\> write new message in file or dedicated elasticsearch index

}

I found this topic:  
[https://logstash.jira.com/browse/LOGSTASH-1375](https://logstash.jira.com/browse/LOGSTASH-1375)

but unfortunately, this solution does not seem to work.

Any suggestions?

Regards,  
Matteo

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [January 12, 2016, 6:47pm UTC](https://discuss.elastic.co/t/exception-handling/38989/2 "2016-01-12T18:47:01Z")

</div>

If the date parsing fails the message will by default get the tag `_dateparsefailure` so you can do something like this:

```auto
filter {
  date {
    ...
  }
}

output {
  if "_dateparsefailure" in [tags] {
    file {
      path => ".../date_parse_errors.log"
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 5:16am UTC](https://discuss.elastic.co/t/exception-handling/38989/3 "2017-07-06T05:16:00Z")

</div>


