~ubuntu-branches/ubuntu/wily/steam/wily

« back to all changes in this revision

Viewing changes to server/libraries/Visconte.pmod/Request.pmod/Message.pike

  • Committer: Package Import Robot
  • Author(s): Felix Geyer
  • Date: 2013-10-29 19:51:18 UTC
  • mfrom: (1.1.4) (0.1.4 trusty-proposed)
  • Revision ID: package-import@ubuntu.com-20131029195118-b9bxciz5hwx5z459
Tags: 1:1.0.0.39-2ubuntu1
Add an epoch to the version number as there was an unrelated steam package
in the archive with a higher version number.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
 
3
 
 
4
 
/**
5
 
 * <p>class Message - A simple class for representing a message. The Constructor is designed to 
6
 
 * receiver common throw messages from pike. Otherwise a Message is designed as follows:
7
 
 * 1. msg: Message as string,
8
 
 * 2. backtrace: Output from function backtrace()
9
 
 * 3. errorcode: The error id (see MessageCode for details)
10
 
 * 4. about: The id of the item the message deals about </p>
11
 
 */
12
 
 
13
 
/**
14
 
 * <p>Constant for error</p>
15
 
 */
16
 
    public constant  ERROR = 1;
17
 
 
18
 
/**
19
 
 * <p>Constant for warning</p>
20
 
 */
21
 
    public constant  WARNING = 2;
22
 
 
23
 
/**
24
 
 * <p>Constant for status</p>
25
 
 */
26
 
    public constant  STATUS = 3;
27
 
 
28
 
/**
29
 
 * <p>The errorcode of the message (see MessageCode for details)</p>
30
 
 */
31
 
    public int errorcode = 0;
32
 
/**
33
 
 * <p>The type of the message, either ERROR, WARNING or STATUS</p>
34
 
 */
35
 
    public int type = 0;
36
 
    
37
 
/**
38
 
 * <p>The message to send</p>
39
 
 */
40
 
    public string msg="";
41
 
    
42
 
/**
43
 
 * <p>the backtrace of the message</p>
44
 
 */
45
 
    public string backtrace="";
46
 
 
47
 
/**
48
 
 * <p>The id resp. item id the message is about.</p>
49
 
 */
50
 
    public string about="";
51
 
 
52
 
    
53
 
    
54
 
/**
55
 
 * <p>Constructor for the Message</p>
56
 
 * 
57
 
 * accepts array of this form ({ string, backtrace(),int,stirng}) );
58
 
 * @example throw( ({ "My Message", backtrace(),11,"id_of_item"}) );
59
 
 * @param msg - the array with the informations
60
 
 * @param msg - the message
61
 
 * @param about - the id about the message deals 
62
 
 */
63
 
    public void create(array msg) {        
64
 
        //set the message
65
 
        this_program::msg= (string)msg[0];
66
 
        backtrace=sprintf("%O",msg[1]);
67
 
        
68
 
        if(has_index(msg, 2))
69
 
        this_program::errorcode = msg[2];
70
 
        if(errorcode%2)
71
 
                type = ERROR;
72
 
        else
73
 
                type = WARNING;
74
 
        if(has_index(msg, 3))
75
 
        this_program::about = msg[3];
76
 
        
77
 
        
78
 
    } 
79
 
 
80
 
/**
81
 
 * <p>Renders a string represenation of the message</p>
82
 
 * 
83
 
 * 
84
 
 * @return string with the dump
85
 
 */
86
 
    public string to_string() {        
87
 
        string message_type;
88
 
        
89
 
        switch (type)
90
 
        {
91
 
                case ERROR:
92
 
                message_type="Error";
93
 
                break;
94
 
                
95
 
                case WARNING:
96
 
                message_type="Warning";
97
 
                break;
98
 
                
99
 
                case STATUS:
100
 
                message_type="Status";
101
 
                break;
102
 
        }
103
 
        return "\n\n"+message_type+"------------------------------\n"+
104
 
                "Messagecode: "+errorcode+"\n Message: "+msg+"\n About:"+about+"\n Backtrace:"+backtrace+
105
 
                "\n------------------------------\n";
106
 
                
107
 
    } 
108
 
    
109
 
/**
110
 
 * <p>Indictas wheter this message is an errormessage or not</p>
111
 
 * 
112
 
 * 
113
 
 * @return boold
114
 
 */
115
 
    public int is_error()
116
 
    {
117
 
            if(type==ERROR)
118
 
                    return 1;
119
 
            else
120
 
                    return 0;
121
 
    }