• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

CLI interface to medialist (fossil mirror)


Commit MetaInfo

Révision661580821ec177b0aecf3ea679e15ba54952f689 (tree)
l'heure2022-01-25 10:24:14
Auteurmio <stigma@disr...>
Commitermio

Message de Log

add MLError.fileReadError and replace throwing exceptions.

FossilOrigin-Name: a1972972f4e100c9f0f54762592ae77234c2478a86ad8dfe855d05b4005f073f

Change Summary

Modification

--- a/medialist.d
+++ b/medialist.d
@@ -90,6 +90,7 @@ enum MLError
9090 invalidArgs,
9191 fileDoesNotExist,
9292 fileAlreadyOpen,
93+ fileReadError,
9394 itemNotFound,
9495 }
9596
@@ -131,10 +132,14 @@ void ml_free_list(MediaList* list)
131132 GC.free(list);
132133 }
133134
134-MediaListHeader[] ml_fetch_headers(MediaList* list)
135+MediaListHeader[] ml_fetch_headers(MediaList* list, MLError* err = null)
135136 {
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+ }
138143
139144 File listFile = File(list.filePath);
140145
@@ -174,8 +179,12 @@ MediaListHeader[] ml_fetch_headers(MediaList* list)
174179 configurations[sections[0]] = sections[1];
175180 }
176181
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+ }
179188
180189 string[] sections = line.strip().split("\t");
181190 foreach(size_t idx, ref string section; sections) {