Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=cfpm.git;a=commitdiff;h=da2af752959dd61aa8392f0a4789535531d0d2e1
commit da2af752959dd61aa8392f0a4789535531d0d2e1 Author: Priyank <priy...@frugalware.org> Date: Thu Jun 4 16:28:51 2009 +0530 perform some error handling * PrintStatus: print an error only when en is not 0 diff --git a/main.m b/main.m index fc04109..d947c36 100644 --- a/main.m +++ b/main.m @@ -9,13 +9,13 @@ int main(void) pacman_initialize ("/"); /* register the local package database */ - db = [[Database new] Register:"local"]; + db = [[Database new] Register: "local"]; - /* we should print an error only when there _is_ an error - otherwise this would return "Unexpected Error". The correct way - is to check the return value of the functions before calling PrintStatus - */ - //[db PrintStatus:stderr]; + if ( [db Status] ) + { + [db PrintStatus:stderr]; + return 1; + } /* query the database */ pkg = [db ReadPackage: "gfpm"]; diff --git a/pm.m b/pm.m index bf6dd46..ce6ebee 100644 --- a/pm.m +++ b/pm.m @@ -5,7 +5,10 @@ - (STR) StatusString { return pacman_strerror(en); } - PrintStatus: (IOD) f { - fprintf(f,"%s\n",[self StatusString]); + if (en != 0) + { + fprintf(f,"%s\n",[self StatusString]); + } return self; } - ResetStatus @@ -23,8 +26,11 @@ @implementation Database - Register: (STR) s { + if( (db = pacman_db_register(s)) == NULL ) + { [self _set_status]; + } return self; } - Unregister _______________________________________________ Frugalware-git mailing list Frugalware-git@frugalware.org http://frugalware.org/mailman/listinfo/frugalware-git