Moved core implementation to the library
[cascardo/atompub.git] / src / error.c
diff --git a/src/error.c b/src/error.c
deleted file mode 100644 (file)
index a8e08e4..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- *  Copyright (C) 2008  Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License along
- *  with this program; if not, write to the Free Software Foundation, Inc.,
- *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-
-#include <atompub/atom.h>
-
-#include <glib.h>
-#include <gio/gio.h>
-
-struct _atom_error
-{
-  int code;
-  char * message;
-};
-
-AtomError *
-atom_error_new ()
-{
-  AtomError *error;
-  error = g_slice_new (AtomError);
-  error->code = 0;
-  error->message = NULL;
-  return error;
-}
-
-void
-atom_error_delete (AtomError *error)
-{
-  if (error->message)
-    g_free (error->message);
-  g_slice_free (AtomError, error);
-}
-
-int
-atom_error_code (AtomError *error)
-{
-  return error->code;
-}
-
-void
-atom_error_code_set (AtomError *error, int code)
-{
-  error->code = code;
-}
-
-char *
-atom_error_message (AtomError *error)
-{
-  return error->message;
-}
-
-void
-atom_error_message_set (AtomError *error, char *message)
-{
-  error->message = g_strdup (message);
-}
-
-AtomError *
-atom_error_new_from_gerror (GError *error)
-{
-  AtomError *aerr;
-  aerr = atom_error_new ();
-  if (error->domain == G_FILE_ERROR)
-    {
-      switch (error->code)
-       {
-         case G_FILE_ERROR_EXIST:
-         case G_FILE_ERROR_ACCES:
-         case G_FILE_ERROR_PERM:
-           aerr->code = 403;
-           break;
-         case G_FILE_ERROR_NOENT:
-           aerr->code = 404;
-           break;
-         default:
-           aerr->code = 500;
-           break;
-       }
-    }
-  else if (error->domain = G_IO_ERROR)
-    {
-      switch (error->code)
-       {
-         case G_IO_ERROR_NOT_FOUND:
-           aerr->code = 404;
-           break;
-         default:
-           aerr->code = 500;
-           break;
-       }
-    }
-  else
-    {
-      aerr->code = 500;
-    }
-  aerr->message = g_strdup (error->message);
-  return aerr;
-}