LCOV - code coverage report
Current view: top level - src - fdb_errors.cc (source / functions) Hit Total Coverage
Test: coverage.info.cleaned Lines: 39 39 100.0 %
Date: 2015-01-12 15:17:13 Functions: 1 1 100.0 %
Branches: 37 37 100.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
       2                 :            : /*
       3                 :            :  *     Copyright 2014 Couchbase, Inc
       4                 :            :  *
       5                 :            :  *   Licensed under the Apache License, Version 2.0 (the "License");
       6                 :            :  *   you may not use this file except in compliance with the License.
       7                 :            :  *   You may obtain a copy of the License at
       8                 :            :  *
       9                 :            :  *       http://www.apache.org/licenses/LICENSE-2.0
      10                 :            :  *
      11                 :            :  *   Unless required by applicable law or agreed to in writing, software
      12                 :            :  *   distributed under the License is distributed on an "AS IS" BASIS,
      13                 :            :  *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      14                 :            :  *   See the License for the specific language governing permissions and
      15                 :            :  *   limitations under the License.
      16                 :            :  */
      17                 :            : 
      18                 :            : #include <stdlib.h>
      19                 :            : #include "libforestdb/forestdb.h"
      20                 :            : 
      21                 :            : LIBFDB_API
      22                 :         42 : const char* fdb_error_msg(fdb_status err_code)
      23                 :            : {
      24   [ +  +  +  +  :         42 :     switch (err_code)
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
                +  +  + ]
      25                 :            :     {
      26                 :            :         case FDB_RESULT_SUCCESS:
      27                 :          2 :             return "success";
      28                 :            : 
      29                 :            :         case FDB_RESULT_INVALID_ARGS:
      30                 :          1 :             return "invalid arguments";
      31                 :            : 
      32                 :            :         case FDB_RESULT_OPEN_FAIL:
      33                 :          1 :             return "error opening file";
      34                 :            : 
      35                 :            :         case FDB_RESULT_NO_SUCH_FILE:
      36                 :          2 :             return "no such file";
      37                 :            : 
      38                 :            :         case FDB_RESULT_WRITE_FAIL:
      39                 :          1 :             return "error writing to file";
      40                 :            : 
      41                 :            :         case FDB_RESULT_READ_FAIL:
      42                 :          1 :             return "error reading from file";
      43                 :            : 
      44                 :            :         case FDB_RESULT_CLOSE_FAIL:
      45                 :          1 :             return "error closing a file";
      46                 :            : 
      47                 :            :         case FDB_RESULT_COMMIT_FAIL:
      48                 :          1 :             return "commit operation failed";
      49                 :            : 
      50                 :            :         case FDB_RESULT_ALLOC_FAIL:
      51                 :          1 :             return "failed to allocate memory";
      52                 :            : 
      53                 :            :         case FDB_RESULT_KEY_NOT_FOUND:
      54                 :          2 :             return "key not found";
      55                 :            : 
      56                 :            :         case FDB_RESULT_RONLY_VIOLATION:
      57                 :          2 :             return "database is read-only";
      58                 :            : 
      59                 :            :         case FDB_RESULT_COMPACTION_FAIL:
      60                 :          1 :             return "compaction operation failed";
      61                 :            : 
      62                 :            :         case FDB_RESULT_ITERATOR_FAIL:
      63                 :          1 :             return "iterator operation failed";
      64                 :            : 
      65                 :            :         case FDB_RESULT_SEEK_FAIL:
      66                 :          1 :             return "seek failure";
      67                 :            : 
      68                 :            :         case FDB_RESULT_FSYNC_FAIL:
      69                 :          1 :             return "fsync failure";
      70                 :            : 
      71                 :            :         case FDB_RESULT_CHECKSUM_ERROR:
      72                 :          1 :             return "checksum error";
      73                 :            : 
      74                 :            :         case FDB_RESULT_FILE_CORRUPTION:
      75                 :          1 :             return "data corruption in file";
      76                 :            : 
      77                 :            :         case FDB_RESULT_COMPRESSION_FAIL:
      78                 :          1 :             return "document compression failure";
      79                 :            : 
      80                 :            :         case FDB_RESULT_NO_DB_INSTANCE:
      81                 :          1 :             return "database instance not found";
      82                 :            : 
      83                 :            :         case FDB_RESULT_FAIL_BY_ROLLBACK:
      84                 :          1 :             return "operation failed due to rollback";
      85                 :            : 
      86                 :            :         case FDB_RESULT_INVALID_CONFIG:
      87                 :          2 :             return "invalid configuration";
      88                 :            : 
      89                 :            :         case FDB_RESULT_MANUAL_COMPACTION_FAIL:
      90                 :          1 :             return "manual compaction failed";
      91                 :            : 
      92                 :            :        case FDB_RESULT_INVALID_COMPACTION_MODE:
      93                 :          1 :             return "invalid compaction mode";
      94                 :            : 
      95                 :            :         case FDB_RESULT_FILE_IS_BUSY:
      96                 :          1 :             return "file handle is busy";
      97                 :            : 
      98                 :            :         case FDB_RESULT_FILE_REMOVE_FAIL:
      99                 :          1 :             return "file removal operation failed";
     100                 :            : 
     101                 :            :         case FDB_RESULT_FILE_RENAME_FAIL:
     102                 :          1 :             return "file rename operation failed";
     103                 :            : 
     104                 :            :         case FDB_RESULT_TRANSACTION_FAIL:
     105                 :          1 :             return "transaction operation failed";
     106                 :            : 
     107                 :            :         case FDB_RESULT_FAIL_BY_TRANSACTION:
     108                 :          1 :             return "operation failed due to active transaction";
     109                 :            : 
     110                 :            :         case FDB_RESULT_FAIL_BY_COMPACTION:
     111                 :          1 :             return "operation failed due to active compaction";
     112                 :            : 
     113                 :            :         case FDB_RESULT_TOO_LONG_FILENAME:
     114                 :          1 :             return "filename is too long";
     115                 :            : 
     116                 :            :         case FDB_RESULT_INVALID_HANDLE:
     117                 :          1 :             return "ForestDB handle is invalid";
     118                 :            : 
     119                 :            :         case FDB_RESULT_KV_STORE_NOT_FOUND:
     120                 :          1 :             return "KV store not found in database";
     121                 :            : 
     122                 :            :         case FDB_RESULT_KV_STORE_BUSY:
     123                 :          1 :             return "there is an active open handle on the kvstore";
     124                 :            : 
     125                 :            :         case FDB_RESULT_INVALID_KV_INSTANCE_NAME:
     126                 :          1 :             return "same KV instance name already exists";
     127                 :            : 
     128                 :            :         case FDB_RESULT_INVALID_CMP_FUNCTION:
     129                 :          1 :             return "custom compare function is assigned incorrectly";
     130                 :            : 
     131                 :            :         case FDB_RESULT_IN_USE_BY_COMPACTOR:
     132                 :          1 :             return "file is in use by compactor, retry later";
     133                 :            : 
     134                 :            :         default:
     135                 :         42 :             return "unknown error";
     136                 :            :     }
     137                 :            : }

Generated by: LCOV version 1.11