Code coverage report for lib/errors.js

Statements: 58.82% (20 / 34)      Branches: 100% (0 / 0)      Functions: 53.85% (7 / 13)      Lines: 58.82% (20 / 34)     

All files » lib/ » errors.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87                                              1   1   3 3     3 3 3             82 82 82                         7 7   7     1 1             2 2 2     1 1                      
/*
 * Copyright 2014 Telefonica Investigación y Desarrollo, S.A.U
 *
 * This file is part of iotagent-lwm2m-lib
 *
 * iotagent-lwm2m-lib is free software: you can redistribute it and/or
 * modify it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the License,
 * or (at your option) any later version.
 *
 * iotagent-lwm2m-lib 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 Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public
 * License along with iotagent-lwm2m-lib.
 * If not, seehttp://www.gnu.org/licenses/.
 *
 * For those usages not covered by the GNU Affero General Public License
 * please contact with::[contacto@tid.es]
 */
 
'use strict';
 
module.exports = {
    BadRequestError: function(message) {
        this.name = 'BAD_REQUEST_ERROR';
        this.message = 'The request was not build correctly: ' + message;
    },
    DeviceNotFound: function(id) {
        this.name = 'DEVICE_NOT_FOUND';
        this.message = 'The device with id: ' + id + ' was not found';
        this.code = '4.04';
    },
    ClientError: function(code) {
        this.name = 'CLIENT_ERROR';
        this.message = 'Error code recieved from the client: ' + code;
    },
    ObjectNotFound: function(id) {
        this.name = 'OBJECT_NOT_FOUND';
        this.message = 'The object with id: ' + id + ' was not found in the registry';
        this.code = '4.04';
    },
    UnsupportedAttributes: function (attributes) {
        this.name = 'UNSUPPORTED_ATTRIBUTES';
        this.message = 'Unsupported attributes writting to object URI: ' + JSON.stringify(attributes);
        this.code = '4.00';
    },
    ServerNotFound: function(url) {
        this.name = 'SERVER_NOT_FOUND';
        this.message = 'No server was found on url: ' + url;
        this.code = '4.04';
    },
    ResourceNotFound: function(id, type, objectId) {
        this.name = 'RESOURCE_NOT_FOUND';
        this.message = 'The resource with id: ' + id + ' for the object with type ' + type + ' id ' + objectId +
            ' was not found in the registry';
        this.code = '4.04';
    },
    WrongObjectUri: function(uri) {
        this.name = 'WRONG_OBJECT_URI';
        this.message = 'Tried to parse wrong object URI: ' + uri;
    },
    InternalDbError: function(msg) {
        this.name = 'INTERNAL_DB_ERROR';
        this.message = 'An internal DB Error happened: ' + msg;
    },
    TypeNotFound: function(url) {
        this.name = 'TYPE_NOT_FOUND';
        this.message = 'No type matching found for URL ' + url;
        this.code = '4.04';
    },
    IllegalTypeUrl: function(url) {
        this.name = 'ILLEGAL_TYPE_URL';
        this.message = 'Illegal URL for type: ' + url + '. Types begining with "/rd" are not allowed';
    },
    RegistrationFailed: function(code) {
        this.name = 'REGISTRATION_FAILED';
        this.message = 'Registration to the Lightweight M2M server failed with code: ' + code;
    },
    IllegalMethodAttributes: function(code) {
        this.name = 'ILLEGAL_METHOD_ATTRIBUTES';
        this.message = 'The method was called with wrong number or type of attributes ' +
            'or at least one mandatory attribute is empty';
    }
};