Return error if backend is not able to tell a feed from an entry
authorThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Sun, 31 Aug 2008 20:04:30 +0000 (17:04 -0300)
committerThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Sun, 31 Aug 2008 20:04:30 +0000 (17:04 -0300)
src/backend.c

index 516738f..d71eb29 100644 (file)
@@ -99,11 +99,20 @@ int
 atom_is_feed (AtomCtx *ctx, AtomID *id)
 {
   AtomBackend *backend;
+  AtomError *aerr;
   backend = atom_backend (ctx);
   if (backend && backend->is_feed)
     {
       return backend->is_feed (ctx, id);
     }
+  /* Frontend may make the decision of whether the requested resource is
+   * a feed or not. If it is not able to do so and backend isn't either,
+   * it is an error.
+   */
+  aerr = atom_error_new ();
+  atom_error_code_set (aerr, 404);
+  atom_error_message_set (aerr, "Not Found");
+  atom_error_set (ctx, aerr);
   return 0;
 }
 
@@ -125,6 +134,7 @@ AtomResource *
 atom_retrieve_resource (AtomCtx *ctx, AtomID *id)
 {
   AtomResource *res;
+  res = NULL;
   if (atom_is_feed (ctx, id))
     {
       AtomFeed *feed;
@@ -134,7 +144,7 @@ atom_retrieve_resource (AtomCtx *ctx, AtomID *id)
       res = atom_resource_new_from_feed (feed);
       atom_feed_delete (feed);
     }
-  else
+  else if (atom_error_get (ctx) != NULL)
     {
       AtomEntry *entry;
       entry = atom_retrieve_entry (ctx, id);