From: Wolf P. <gt...@ja...> - 2007-10-06 11:54:27
|
Hello, Axel Simon wrote: > The stores in the ModelView directory aren't quite complete yet. I > noticed the absence of a function with which you can get the full store. > These function are in the repository, but obviously weren't in the last > release. There is now a function: > > listStoreToList :: ListStore a -> IO [a] > > which retrieves the whole content as a list. You could workaround by > extracting element by element until the function listStoreGetValue > throws an exception. This sucks, but then you could perhaps use this > function whenever your application is built against the current release > of Gtk2Hs. I tried to do it like this in a function to print the contents of the list store, namely write a function that iterates over a ListStore using an exception handler to detect the end of the list. However, the exception is not caught. This is the code, which is initially called by "printList myliststore 0": printList :: New.ListStore MyType -> Int -> IO () printList ls index = do catchGError (do entry <- listStoreGetValue ls index putStr $ show entry printList ls (index+1) ) (\error -> return()) It neither works if I use "catch" instead of "catchGError". The list gets printed correctly, but I always run into an "index out of bounds" error, which is not caught. How can I catch this error? Thanks in advance, Wolf |