# error_handling

> ## Directory

> > eXtremeDB_rt/samples/error_handling

> ## Description

> > Demonstrates handling of eXtremeDB/rt fatal errors

> ## Used API

> > mco_error_set_handler(), mco_error_set_handler_ex()

> ## Code snippet

> >         /* Implement error handler */
> >         static void errhandler(MCO_RET n)
> >         {
> >             printf("\neXtremeDB/rt runtime fatal error: %d", n);
> >             getchar();
> >             sample_os_shutdown();
> >             exit( 0 );
> >         }

> >         /* Implement extended error handler */
> >         static void extended_errhandler(MCO_RET errcode, const char* file, int line)
> >         {
> >           printf("\neXtremeDB/rt runtime fatal error: %d on line %d of file %s", errcode
> >         , line, file);
> >           getchar();

> >           sample_os_shutdown();
> >           exit( 0 );
> >         }

> >         ....

> >         /* Set the error handler to be called from the eXtremeDB/rt runtime if a fatal error occurs */
> >           mco_error_set_handler(&errhandler);

> >           /* Set the error handler to be called from the eXtremeDB/rt runtime if a fatal error occurs */
> >           mco_error_set_handler_ex(&extended_errhandler);

> >           /* Start eXtremeDB/rt runtime */
> >           mco_runtime_start();

> ## What to expect as an output

> >         Insert 100 test records ..........

> >     	Find record with index == 79 :
> >     	79: Record 79

> >     	Find record with index == 179 :
> >     	Record not found for index 179