1414#include <string.h>
1515#include <errno.h>
1616
17- void err_title_msg (const char * seg , const char * file , int line ) {
17+ void err_title_msg (int compileError , int parameterError ) {
18+ const char * seg ;
19+ const char * file ;
20+ int line ;
21+
22+ if (compileError ) {
23+ file = comp_bc_sec ;
24+ line = comp_line ;
25+ seg = WORD_COMP ;
26+ } else {
27+ file = prog_file ;
28+ line = prog_line ;
29+ seg = WORD_RTE ;
30+ if (ctask -> parent > 0 && parameterError ) {
31+ task_t * parent = taskinfo (ctask -> parent );
32+ line = parent -> line ;
33+ file = parent -> file ;
34+ }
35+ }
36+
37+ const char * slash = strrchr (file , '/' );
38+ if (slash ) {
39+ file = slash + 1 ;
40+ }
41+
1842 gsb_last_line = line ;
1943 gsb_last_error = prog_error ;
2044 strlcpy (gsb_last_file , file , sizeof (gsb_last_file ));
@@ -80,7 +104,7 @@ void sc_raise(const char *format, ...) {
80104 va_end (args );
81105
82106 if (comp_bc_sec ) {
83- err_title_msg (WORD_COMP , comp_bc_sec , comp_line );
107+ err_title_msg (1 , 0 );
84108 }
85109 if (size ) {
86110 va_start (args , format );
@@ -102,7 +126,7 @@ void rt_raise(const char *format, ...) {
102126 unsigned size = vsnprintf (NULL , 0 , format , args );
103127 va_end (args );
104128
105- err_title_msg (WORD_RTE , prog_file , prog_line );
129+ err_title_msg (0 , strcmp ( format , ERR_PARAM_NUM ) == 0 );
106130 if (size ) {
107131 va_start (args , format );
108132 va_err_detail_msg (format , args , size );
@@ -161,7 +185,7 @@ void err_syntax(int keyword, const char *fmt) {
161185 fmt_p ++ ;
162186 }
163187
164- err_title_msg (WORD_RTE , prog_file , prog_line );
188+ err_title_msg (0 , 0 );
165189 err_detail_msg (ERR_SYNTAX );
166190 err_stack_msg ();
167191 log_printf ("Expected:" );
@@ -355,6 +379,10 @@ void err_network() {
355379 rt_raise (ERR_NETWORK );
356380}
357381
382+ void err_abnormal_exit () {
383+ rt_raise (ERR_ABNORMAL_EXIT );
384+ }
385+
358386/**
359387 * the DONE message
360388 */
@@ -458,7 +486,7 @@ void err_throw_str(const char *err) {
458486 }
459487
460488 if (!caught ) {
461- err_title_msg (WORD_RTE , prog_file , prog_line );
489+ err_title_msg (0 , 0 );
462490 err_detail_msg (err );
463491 err_stack_msg ();
464492 trace_done = 1 ;
@@ -477,7 +505,7 @@ void err_throw_str(const char *err) {
477505 if (!caught ) {
478506 prog_error = errRuntime ;
479507 if (!trace_done ) {
480- err_title_msg (WORD_RTE , prog_file , prog_line );
508+ err_title_msg (0 , 0 );
481509 err_detail_msg (err );
482510 err_stack_msg ();
483511 }
0 commit comments