# mco_trans_set_error
RT

### Prototype

        MCO_RET mco_trans_set_error(mco_trans_h t, MCO_RET errcode);

### Arguments

t | Transaction handle
errcode | Error code to be set

### Description

> Sets error state for the transaction. Application can use the function to force the database kernel to interrupt the current transaction. Specifically an external timer can call the function to set the `MCO_E_INTERRUPTED` error code for the given transaction. For example:

>         static void timer_handler (mco_db_h db)
>         {
>             mco_trans_h t;
>             if (mco_trans_get_current(db, &t) == MCO_S_OK) {
>                  mco_trans_set_error(t, MCO_E_INTERRUPTED);
>             }
>         }

### Return Codes

MCO_S_OK | Error code set successfully
MCO_E_INTERRUPTED | Transaction was interrupted by timer, callback or another transaction

### Files

Header file:
mco.h
Source file:
target/mcolib/mcotrans.c
Library:
libmcolib.a