Scid  4.7.0
errors.tcl
Go to the documentation of this file.
1 # Copyright (C) 2014 Fulvio Benini
2 #
3 # This file is part of Scid (Shane's Chess Information Database).
4 #
5 # Scid is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation.
8 #
9 # Scid is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with Scid. If not, see <http://www.gnu.org/licenses/>.
16 
17 namespace eval ERROR {
18  proc getErrorMsg {} {
19  if {! [info exists ::ERROR::msg($::errorCode)] } {
20  return "Unknown error: $::errorCode\n\n$::errorInfo"
21  }
22  regexp {(.*?)while executing.*} $::errorInfo -> extra
23  return "$::ERROR::msg($::errorCode)\n\n$extra"
24  }
25 
26  proc MessageBox { {extra ""} {title "ERROR"} } {
27  tk_messageBox -icon warning -type ok -parent . \
28  -title "$title" -message "$extra\n[getErrorMsg]"
29  }
30 
31  set UserCancel 2
32  set BadArg 3
33  set FileOpen 101
34  set FileWrite 102
35  set FileRead 103
36  set FileSeek 104
37  set BadMagic 105
38  set FileNotOpen 106
39  set FileInUse 107
40  set FileMode 108
41  set FileVersion 109
42  set OldScidVersion 110
43  set FileReadOnly 111
44  set CompactRemove 121
45  set MallocFailed 151
46  set CorruptData 152
47  set Corrupt 152
48  set Full 201
49  set NameNotFound 202
50  set NotFound 202
51  set NameExists 203
52  set Exists 203
53  set NameBaseEmpty 204
54  set Empty 204
55  set NoMatchFound 205
56  set NameDataLoss 206
57  set NameTooLong 207
58  set NameLimit 208
59  set OffsetLimit 209
60  set GameLengthLimit 210
61  set NumGamesLimit 211
62  set InvalidFEN 301
63  set InvalidMove 302
64  set PieceCount 303
65  set Game 400
66  set EndOfMoveList 401
67  set StartOfMoveList 402
68  set NoVariation 403
69  set EmptyVariation 404
70  set VariationLimit 405
71  set Decode 406
72  set GameFull 407
73  set PGNTag 501
74  set BufferFull 601
75  set BufferRead 602
76  set CodecUnsupFeat 701
77 
78 }
79 
80 
81 #TODO: improve and translate the messages
82 after idle {
83  set ::ERROR::msg($::ERROR::UserCancel) \
84  "Operation canceled."
85  set ::ERROR::msg($::ERROR::BadArg) \
86  "Wrong parameters."
87  set ::ERROR::msg($::ERROR::FileOpen) \
88  "Error: can not open file."
89  set ::ERROR::msg($::ERROR::FileWrite) \
90  "Error writing file."
91  set ::ERROR::msg($::ERROR::FileRead) \
92  "Error: can not read file."
93  set ::ERROR::msg($::ERROR::FileSeek) \
94  "Error: can not seek in file."
95  set ::ERROR::msg($::ERROR::BadMagic) \
96  "Error: bad magic (corrupted file?)."
97  set ::ERROR::msg($::ERROR::FileNotOpen) \
98  "Error: the file is not open."
99  set ::ERROR::msg($::ERROR::FileInUse) \
100  "Error: the file is already in use."
101  set ::ERROR::msg($::ERROR::FileMode) \
102  "Error: file mode."
103  set ::ERROR::msg($::ERROR::FileVersion) \
104  "Database version newer than Scid; please upgrade Scid."
105  set ::ERROR::msg($::ERROR::OldScidVersion) \
106  "Old format Scid file, now out of date."
107  set ::ERROR::msg($::ERROR::FileReadOnly) \
108  $::tr(ErrReadOnly)
109 
110  set ::ERROR::msg(CompactCreate) \
111  "A temporary database from a previous unsuccessfully compact operation already exists.\nPlease remove the files with suffix __COMPACT__ and retry.\n"
112  set ::ERROR::msg($::ERROR::CompactRemove) \
113  "A compacted database has been successfully created with suffix __COMPACT__.\nHowever Scid could not remove the original database (due to insufficient privileges or because a file is opened in another program).\nPlease rename it manually.\n"
114  set ::ERROR::msg($::ERROR::CorruptData) \
115  "Error while processing data: corrupted.\n"
116  set ::ERROR::msg($::ERROR::Full) \
117  "Error: insufficient space"
118  set ::ERROR::msg($::ERROR::NameDataLoss) \
119  "Some names (player, event, site or round) are missing and have been replaced by \"?\"\nCompact the database to make the changes permanent."
120  set ::ERROR::msg($::ERROR::NameTooLong) \
121  "The entered values are too long"
122  set ::ERROR::msg($::ERROR::NameLimit) \
123  "The maximum number of different names allowed by this database type has been reached"
124  set ::ERROR::msg($::ERROR::OffsetLimit) \
125  "The maximum space for games allowed by this database type has been reached"
126  set ::ERROR::msg($::ERROR::GameLengthLimit) \
127  "The maximum length for a game allowed by this database type has been reached"
128  set ::ERROR::msg($::ERROR::NumGamesLimit) \
129  "The maximum number of games allowed by this database type has been reached"
130 
131  set ::ERROR::msg($::ERROR::CodecUnsupFeat) \
132  "The requested function is not supported by this type of database."
133 }