]> git.donarmstrong.com Git - lilypond.git/blob - lily/warn.cc
2b9f1db767d265d4a5a2cfcef701e71834aab139
[lilypond.git] / lily / warn.cc
1 #include "proto.hh"
2 #include "plist.hh"
3 #include "debug.hh"
4 #include "my-lily-lexer.hh"
5 #include "moment.hh"
6 #include "time-description.hh"
7 #include "source-file.hh"
8 #include "source.hh"
9 #include "main.hh"
10
11 ostream &warnout (cerr);
12 ostream *mlog(&cerr);
13 /*
14 void
15 warning(String s)
16 {
17     WARN << s;
18 }
19 */
20
21 void
22 error(String s)
23 {
24     cerr <<  "error: " << s << "\n";
25         
26     exit(1);
27 }
28
29 void
30 error_t(String const & s, Moment const & r)
31 {
32     String t_mom = String(trunc(r)) + String(r - Moment(trunc(r)));
33     String e=s+ " (t = " +  t_mom + ")";
34     error(e);
35 }
36
37 void
38 error_t(String const & s, Time_description const &t_tdes)
39 {
40     String e=s+ " (at t=" + String(t_tdes.bars_i_) + ": " + String(t_tdes.whole_in_measure_) + ")\n";
41     error(e);
42 }
43
44 void
45 message( String message_str, char const* context_ch_C )
46 {
47     String str = "";            //"lilypond: ";// GNU format messages!
48     Source_file* sourcefile_l = source_l_g->sourcefile_l( context_ch_C );
49     if ( sourcefile_l ) {
50         str += sourcefile_l->file_line_no_str(context_ch_C) + String(": ");
51     }
52     str += message_str;
53     if ( sourcefile_l ) {
54         str += ":\n";
55         str += sourcefile_l->error_str( context_ch_C );
56     }
57     if ( busy_parsing() )
58         cerr << endl;
59     cerr << str << endl;
60 }
61
62 void
63 warning( String message_str, char const* context_ch_C )
64 {
65     message( "warning: " + message_str, context_ch_C );
66 }
67
68 void
69 error( String message_str, char const* context_ch_C )
70 {
71     message( message_str, context_ch_C );
72     // since when exits error again?
73     // i-d say: error: errorlevel |= 1; -> no output upon error
74     //          warning: recovery -> output (possibly wrong)
75 /*    if ( lexer )
76         lexer->errorlevel_i_ |= 1;*/
77 //    exit( 1 );
78 }