annotation Raises

Overview

Marks a method or function as potentially raising an exception.

This is usually not necessary for regular Crystal methods because the compiler knows which ones can raise.

This annotation can indicate to the compiler that a C function invokes a user-provided callback that might raise, so it must generate the appropriate exception handling code around the call.

lib LibFoo
  @[Raises]
  fun foo(callback : ->)
end

NOTE The Crystal book has a section about Built-in Annotations: Raises.

Defined in:

annotations.cr