{"size": 2382, "ext": "js", "max_stars_repo_path": "modules/errors/src/Error.js", "max_stars_repo_name": "carlngan/cmp-api", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "modules/errors/src/Error.js", "max_issues_repo_name": "carlngan/cmp-api", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "modules/errors/src/Error.js", "max_forks_repo_name": "carlngan/cmp-api", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 26.7640449438, "max_line_length": 88, "alphanum_fraction": 0.4378673384}
"use strict";

module.exports = class Error {

    constructor(code, optParam1, optParam2, optParam3) {

        this.setCode(code);
        this.setError(true);

        switch (code) {
            // DATABASE
            case "DBA001":
                this.msg = "Unable to create in database: " + optParam1;
                break;
            case "DBA002":
                this.msg = "Unable to find in database: " + optParam1;
                break;
            case "DBA003":
                this.msg = "Unable to update in database: " + optParam1;
                break;
            case "DBA004":
                this.msg = "Unable to delete in database: " + optParam1;
                break;

            // AUTHENTICATION
            case "AUT001":
                this.msg = "Authentication header required.";
                break;
            case "AUT002":
                this.msg = "Authentication header malformed.";
                break;
            case "AUT003":
                this.msg = "Invalid access token (in this case bad username/password).";
                break;
            case "AUT004":
                this.msg = "Unable to authenticate username and password.";
                break;
            case "AUT005":
                this.msg = "Username is required.";
                break;
            case "AUT006":
                this.msg = "Password is required.";
                break;

            // CLAIM
            case "CLA001":
                this.msg = "Claim number required.";
                break;
            case "CLA002":
                this.msg = "Client ID and Client Secret required.";
                break;
            case "CLA003":
                this.msg = "Claim does not exist: " + optParam1;
                break;
            case "CLA004":
                this.msg = "Claim number must be unique";
                break;
            case "CLA005":
                this.msg = "Claim number already exists";
                break;
            default:
                this.msg = "Unknown error";
        }

    }

    setCode(c) {
        this.code = c;
    }
    getCode() {
        return this.code || "";
    }

    setMsg(m) {
        this.msg = m;
    }
    getMsg() {
        return this.msg || "";
    }

    setError(e) {
        this.error = e;
    }
    isError() {
        return this.error;
    }

};
