X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FTSN%2FDbImport.hs;h=3aeb29f26a87756e51a49f0773bf1fd53b5b499e;hb=a163a47ab0aed0072f7868d4b2b28aa4c326e5e1;hp=3646d7c34b7fce77583bac18fbf21bb36d55742a;hpb=da0885d061b23f99a6c9d24b6b823c4654893d9c;p=dead%2Fhtsn-import.git diff --git a/src/TSN/DbImport.hs b/src/TSN/DbImport.hs index 3646d7c..3aeb29f 100644 --- a/src/TSN/DbImport.hs +++ b/src/TSN/DbImport.hs @@ -26,7 +26,13 @@ import Text.XML.HXT.Core ( -- 'Either' with three choices. A "Info" return value means that -- the XML document *was* processed, so it should be removed. -- -data ImportResult = Err String | Info String | Succ Int +data ImportResult = + ImportFailed String -- ^ Failure with an error message. + | ImportSkipped String -- ^ We processed the file, but didn't import it. + -- The reason is contained in the second field. + | ImportSucceeded Int -- ^ We did import records, and here's how many. + | ImportUnsupported String -- ^ We didn't know how to process this file. + -- The second field should contain info. -- | Instances of this type know how to insert themselves into a -- Groundhog database. @@ -50,7 +56,8 @@ import_generic g dummy xml = do runMigration defaultMigrationLogger $ migrate dummy let root_element = unpickleDoc xpickle xml case root_element of - Nothing -> return $ Err "Could not unpickle document in import_generic." + Nothing -> return $ + ImportFailed "Could not unpickle document in import_generic." Just elt -> do ids <- mapM insert (g elt) - return $ Succ (length ids) + return $ ImportSucceeded (length ids)