CLI interface to medialist (fossil mirror)
Révision | 661580821ec177b0aecf3ea679e15ba54952f689 (tree) |
---|---|
l'heure | 2022-01-25 10:24:14 |
Auteur | mio <stigma@disr...> |
Commiter | mio |
add MLError.fileReadError and replace throwing exceptions.
FossilOrigin-Name: a1972972f4e100c9f0f54762592ae77234c2478a86ad8dfe855d05b4005f073f
@@ -90,6 +90,7 @@ enum MLError | ||
90 | 90 | invalidArgs, |
91 | 91 | fileDoesNotExist, |
92 | 92 | fileAlreadyOpen, |
93 | + fileReadError, | |
93 | 94 | itemNotFound, |
94 | 95 | } |
95 | 96 |
@@ -131,10 +132,14 @@ void ml_free_list(MediaList* list) | ||
131 | 132 | GC.free(list); |
132 | 133 | } |
133 | 134 | |
134 | -MediaListHeader[] ml_fetch_headers(MediaList* list) | |
135 | +MediaListHeader[] ml_fetch_headers(MediaList* list, MLError* err = null) | |
135 | 136 | { |
136 | - if (true == list.isOpen) | |
137 | - throw new Exception("List '" ~ list.listName ~ "' is already open for modification"); | |
137 | + if (true == list.isOpen) { | |
138 | + if (null !is err) | |
139 | + *err = MLError.fileAlreadyOpen; | |
140 | + | |
141 | + return null; | |
142 | + } | |
138 | 143 | |
139 | 144 | File listFile = File(list.filePath); |
140 | 145 |
@@ -174,8 +179,12 @@ MediaListHeader[] ml_fetch_headers(MediaList* list) | ||
174 | 179 | configurations[sections[0]] = sections[1]; |
175 | 180 | } |
176 | 181 | |
177 | - if (line is null) | |
178 | - throw new Exception("No header line found"); | |
182 | + if (line is null) { | |
183 | + if (null !is err) | |
184 | + *err = MLError.fileReadError; | |
185 | + | |
186 | + return null; | |
187 | + } | |
179 | 188 | |
180 | 189 | string[] sections = line.strip().split("\t"); |
181 | 190 | foreach(size_t idx, ref string section; sections) { |