LCOV - code coverage report
Current view: top level - Accounts - error.cpp (source / functions) Hit Total Coverage
Test: Code Coverage Lines: 10 26 38.5 %
Date: 2013-04-26 Functions: 1 1 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 3 10 30.0 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * This file is part of libaccounts-qt
       3                 :            :  *
       4                 :            :  * Copyright (C) 2011 Nokia Corporation.
       5                 :            :  *
       6                 :            :  * Contact: Alberto Mardegan <alberto.mardegan@nokia.com>
       7                 :            :  *
       8                 :            :  * This library is free software; you can redistribute it and/or
       9                 :            :  * modify it under the terms of the GNU Lesser General Public License
      10                 :            :  * version 2.1 as published by the Free Software Foundation.
      11                 :            :  *
      12                 :            :  * This library is distributed in the hope that it will be useful, but
      13                 :            :  * WITHOUT ANY WARRANTY; without even the implied warranty of
      14                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
      15                 :            :  * Lesser General Public License for more details.
      16                 :            :  *
      17                 :            :  * You should have received a copy of the GNU Lesser General Public
      18                 :            :  * License along with this library; if not, write to the Free Software
      19                 :            :  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
      20                 :            :  * 02110-1301 USA
      21                 :            :  */
      22                 :            : 
      23                 :            : #include "error.h"
      24                 :            : 
      25                 :            : #include <libaccounts-glib/ag-errors.h>
      26                 :            : 
      27                 :            : namespace Accounts {
      28                 :            : 
      29                 :            : /*!
      30                 :            :  * @class Error
      31                 :            :  * @headerfile error.h Accounts/Error
      32                 :            :  * @brief Base object definition for accounts error handling.
      33                 :            :  */
      34                 :            : 
      35                 :          2 : Error::Error(const GError *error)
      36                 :            : {
      37                 :          2 :     registerType();
      38                 :            : 
      39         [ -  + ]:          2 :     if (error == NULL) {
      40                 :          0 :         m_type = NoError;
      41                 :          0 :         m_message = QString();
      42                 :            :     } else {
      43         [ +  - ]:          2 :         if (error->domain == AG_ERRORS) {
      44   [ -  -  -  -  :          2 :             switch (error->code) {
                   +  - ]
      45                 :            :             case AG_ERROR_DB:
      46                 :          0 :                 m_type = Database;
      47                 :          0 :                 break;
      48                 :            :             case AG_ERROR_DELETED:
      49                 :          0 :                 m_type = Deleted;
      50                 :          0 :                 break;
      51                 :            :             case AG_ERROR_DISPOSED:
      52                 :            :                 // Should never happen here!
      53                 :          0 :                 qCritical() << Q_FUNC_INFO << "Account object is disposed!";
      54                 :          0 :                 m_type = Unknown;
      55                 :          0 :                 break;
      56                 :            :             case AG_ERROR_DB_LOCKED:
      57                 :          0 :                 m_type = DatabaseLocked;
      58                 :          0 :                 break;
      59                 :            :             case AG_ERROR_ACCOUNT_NOT_FOUND:
      60                 :          2 :                 m_type = AccountNotFound;
      61                 :          2 :                 break;
      62                 :            :             default:
      63                 :          0 :                 qWarning() << Q_FUNC_INFO << "Unknown error:" << error->code;
      64                 :          0 :                 m_type = Unknown;
      65                 :          0 :                 break;
      66                 :            :             }
      67                 :            :         } else {
      68                 :            :             // The error is coming from another domain; this shouldn't happen
      69                 :          0 :             qCritical() << Q_FUNC_INFO << "Error is coming from unknown domain";
      70                 :          0 :             m_type = Unknown;
      71                 :            :         }
      72                 :            : 
      73                 :          2 :         m_message = QString::fromUtf8(error->message);
      74                 :            :     }
      75                 :          2 : }
      76                 :            : 
      77                 :          2 : }; // namespace
      78                 :            : 

Generated by: LCOV version 1.9