[basic.contract.handler]

# 6 Basics [[basic]](./#basic)

## 6.11 Contract assertions [[basic.contract]](basic.contract#handler)

### 6.11.3 Contract-violation handler [basic.contract.handler]

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L7956)

The [*contract-violation handler*](#def:contract-violation_handler "6.11.3 Contract-violation handler [basic.contract.handler]") of a program is a function named​::​handle_contract_violation[.](#1.sentence-1)

The contract-violation handler
shall have a single parameter
of type
âlvalue reference to const std​::​contracts​::​contract_violationâ
and shall return void[.](#1.sentence-2)

The contract-violation handler
may have a non-throwing exception specification[.](#1.sentence-3)

The implementation
shall provide a definition of the contract-violation handler,
called the [*default contract-violation handler*](#def:contract-violation_handler,default "6.11.3 Contract-violation handler [basic.contract.handler]")[.](#1.sentence-4)

[*Note [1](#note-1)*:

No declaration
for the default contract-violation handler
is provided by
any standard library header[.](#1.sentence-5)

â *end note*]

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L7979)

*Recommended practice*: The default contract-violation handler
should produce diagnostic output
that suitably formats the most relevant contents
of the std​::​contracts​::​contract_violation object,
rate-limited for potentially repeated violations
of observed contract assertions,
and then return normally[.](#2.sentence-1)

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L7989)

It isimplementation-defined
whether the contract-violation handler
is replaceable ([[dcl.fct.def.replace]](dcl.fct.def.replace#term.replaceable.function "9.6.5 Replaceable function definitions"))[.](#3.sentence-1)

If the contract-violation handler
is not replaceable,
a declaration of a replacement function for the contract-violation handler
is ill-formed, no diagnostic required[.](#3.sentence-2)
