Scid  4.6.5
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 IndexFull 251
59  set InvalidFEN 301
60  set InvalidMove 302
61  set PieceCount 303
62  set Game 400
63  set EndOfMoveList 401
64  set StartOfMoveList 402
65  set NoVariation 403
66  set EmptyVariation 404
67  set VariationLimit 405
68  set Decode 406
69  set GameFull 407
70  set PGNTag 501
71  set BufferFull 601
72  set BufferRead 602
73  set CodecUnsupFeat 701
74 
75 }
76 
77 
78 #TODO: improve and translate the messages
79 after idle {
80  set ::ERROR::msg($::ERROR::UserCancel) \
81  "Operation canceled."
82  set ::ERROR::msg($::ERROR::BadArg) \
83  "Wrong parameters."
84  set ::ERROR::msg($::ERROR::FileOpen) \
85  "Error: can not open file."
86  set ::ERROR::msg($::ERROR::FileWrite) \
87  "Error writing file."
88  set ::ERROR::msg($::ERROR::FileRead) \
89  "Error: can not read file."
90  set ::ERROR::msg($::ERROR::FileSeek) \
91  "Error: can not seek in file."
92  set ::ERROR::msg($::ERROR::BadMagic) \
93  "Error: bad magic (corrupted file?)."
94  set ::ERROR::msg($::ERROR::FileNotOpen) \
95  "Error: the file is not open."
96  set ::ERROR::msg($::ERROR::FileInUse) \
97  "Error: the file is already in use."
98  set ::ERROR::msg($::ERROR::FileMode) \
99  "Error: file mode."
100  set ::ERROR::msg($::ERROR::FileVersion) \
101  "Database version newer than Scid; please upgrade Scid."
102  set ::ERROR::msg($::ERROR::OldScidVersion) \
103  "Old format Scid file, now out of date."
104  set ::ERROR::msg($::ERROR::FileReadOnly) \
105  $::tr(ErrReadOnly)
106 
107  set ::ERROR::msg(CompactCreate) \
108  "A temporary database from a previous unsuccessfully compact operation already exists.\nPlease remove the files with suffix __COMPACT__ and retry.\n"
109  set ::ERROR::msg($::ERROR::CompactRemove) \
110  "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"
111  set ::ERROR::msg($::ERROR::CorruptData) \
112  "Error while processing data: corrupted.\n"
113  set ::ERROR::msg($::ERROR::Full) \
114  "Error: insufficient space"
115  set ::ERROR::msg($::ERROR::NameDataLoss) \
116  "Some names (player, event, site or round) are missing and have been replaced by \"?\"\nCompact the database to make the changes permanent."
117  set ::ERROR::msg($::ERROR::NameTooLong) \
118  "The entered values are too long"
119 
120  set ::ERROR::msg($::ERROR::CodecUnsupFeat) \
121  "The requested function is not supported by this type of database."
122 }