# Rescue as a suffix

**URL:** <https://forum.crystal-lang.org/t/rescue-as-a-suffix/3151>\
**Category:** Help & Support\
**Created:** [April 3, 2021, 4:09pm UTC](https://forum.crystal-lang.org/t/rescue-as-a-suffix/3151 "2021-04-03T16:09:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hutou](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/hutou/32/1337_2.png) [@hutou](https://forum.crystal-lang.org/u/hutou)\
**Post date:** [April 3, 2021, 4:09pm UTC](https://forum.crystal-lang.org/t/rescue-as-a-suffix/3151/1 "2021-04-03T16:09:01Z")

</div>

AFAIK, inline (or suffix) `rescue` does not seem to be documented.

Yet, the following code works :

```
def quit(msg)
  puts msg
  puts "exiting 1"
end
 
td1 = Time.parse("2021-02-29", "%Y-%m-%d", Time::Location.local) rescue quit("Invalid date td1")
p! td1

```

and, even, to avoid a method def

```
td2 = Time.parse("2021-02-29", "%Y-%m-%d", Time::Location.local) rescue begin puts("Invalid date td2"); puts "exiting 1"; end
p! td2

```

Is it safe to use these forms ?

[Edit] : Exception data (message) is not available, however.

---

<div class="post-metadata">

**Author:** ![straight-shoota](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/straight-shoota/32/36_2.png) [@straight-shoota](https://forum.crystal-lang.org/u/straight-shoota)\
**Post date:** [April 3, 2021, 7:51pm UTC](https://forum.crystal-lang.org/t/rescue-as-a-suffix/3151/2 "2021-04-03T19:51:59Z")

</div>

It seems documentation for trailing `rescue` is just missing. But it’s a part of the language and definitely safe to use.  
However, I would recommend `begin/rescue` blocks instead for any kind of complex expressions. The following code is much easier to read and reason about than your example:

```auto
td2 = begin
  Time.parse("2021-02-29", "%Y-%m-%d", Time::Location.local)
rescue
  puts("Invalid date td2")
  puts "exiting 1"
end
p! td2

```
