die_impl.h (1723B)
1 #ifndef MINIROON_DIE_IMPL_H 2 #define MINIROON_DIE_IMPL_H 3 4 #include <assert.h> 5 6 #include <skalibs/strerr.h> 7 8 #include "errors.h" 9 10 void die_on_error(miniroon_error e) { 11 assert(e == miniroon_current_error); 12 if(e == MINIROON_OK) { 13 return; 14 } 15 16 assert(miniroon_errmsg_count <= 8 ); 17 switch(miniroon_errmsg_count) { 18 case 1: 19 strerr_diefn(111, miniroon_errmsg_count, miniroon_errmsg[0]); 20 break; 21 case 2: 22 strerr_diefn(111, miniroon_errmsg_count, miniroon_errmsg[0], miniroon_errmsg[1]); 23 break; 24 case 3: 25 strerr_diefn(111, miniroon_errmsg_count, miniroon_errmsg[0], miniroon_errmsg[1], miniroon_errmsg[2]); 26 break; 27 case 4: 28 strerr_diefn(111, miniroon_errmsg_count, miniroon_errmsg[0], miniroon_errmsg[1], miniroon_errmsg[2], miniroon_errmsg[3]); 29 break; 30 case 5: 31 strerr_diefn(111, miniroon_errmsg_count, miniroon_errmsg[0], miniroon_errmsg[1], miniroon_errmsg[2], miniroon_errmsg[3], miniroon_errmsg[4]); 32 break; 33 case 6: 34 strerr_diefn(111, miniroon_errmsg_count, miniroon_errmsg[0], miniroon_errmsg[1], miniroon_errmsg[2], miniroon_errmsg[3], miniroon_errmsg[4], miniroon_errmsg[5]); 35 break; 36 case 7: 37 strerr_diefn(111, miniroon_errmsg_count, miniroon_errmsg[0], miniroon_errmsg[1], miniroon_errmsg[2], miniroon_errmsg[3], miniroon_errmsg[4], miniroon_errmsg[5], miniroon_errmsg[6]); 38 break; 39 case 8: 40 strerr_diefn(111, miniroon_errmsg_count, miniroon_errmsg[0], miniroon_errmsg[1], miniroon_errmsg[2], miniroon_errmsg[3], miniroon_errmsg[4], miniroon_errmsg[5], miniroon_errmsg[6], miniroon_errmsg[7]); 41 break; 42 default: 43 strerr_diefn(111, 1, "[no error message provided]"); 44 break; 45 } 46 } 47 48 #endif