CARLsim  3.1.3
CARLsim: a GPU-accelerated SNN simulator
UserErrors Class Reference

Static Class for handling user errors. More...

#include <user_errors.h>

Public Types

enum  errorType {
  ALL_NOT_ALLOWED, CAN_ONLY_BE_CALLED_IN_MODE, CAN_ONLY_BE_CALLED_IN_STATE, CANNOT_BE_CALLED_IN_MODE,
  CANNOT_BE_CALLED_IN_STATE, CANNOT_BE_CONN_SYN_AND_COMP, CANNOT_BE_CONN_TWICE, CANNOT_BE_IDENTICAL,
  CANNOT_BE_NEGATIVE, CANNOT_BE_NULL, CANNOT_BE_LARGER, CANNOT_BE_SMALLER,
  CANNOT_BE_OFF, CANNOT_BE_ON, CANNOT_BE_POSITIVE, CANNOT_BE_SET_TO,
  CANNOT_BE_UNKNOWN, CANNOT_BE_ZERO, FILE_CANNOT_CREATE, FILE_CANNOT_OPEN,
  IS_DEPRECATED, MUST_BE_CALLED, MUST_BE_IDENTICAL, MUST_BE_IN_RANGE,
  MUST_BE_LOGGER_CUSTOM, MUST_BE_NEGATIVE, MUST_BE_OFF, MUST_BE_ON,
  MUST_BE_POSITIVE, MUST_BE_SET_TO, MUST_BE_LARGER, MUST_BE_SMALLER,
  MUST_BE_ZERO, MUST_HAVE_SAME_SIGN, NETWORK_ALREADY_RUN, UNKNOWN_GROUP_ID,
  UNKNOWN, WRONG_NEURON_TYPE
}
 an enum of all possible error codes More...
 

Static Public Member Functions

static void assertFalse (bool statement, errorType errorIfAssertionFails, const std::string &errorFunc, const std::string &errorMsgPrefix="", const std::string &errorMsgSuffix="")
 Checks whether assertion statement is false, else throws error. More...
 
static void assertTrue (bool statement, errorType errorIfAssertionFails, const std::string &errorFunc, const std::string &errorMsgPrefix="", const std::string &errorMsgSuffix="")
 Checks whether assertion statement is true, else throws error. More...
 

Detailed Description

This static class handles all possible errors that can be generated by the user. Such errors include incorret calls of CARLsim core functions, conceptual/chronological errors in setting up a network, etc. All these errors are supposed to be fatal; that is, an error message will be printed and CARLsim will exit.

Definition at line 13 of file user_errors.h.

Member Enumeration Documentation

enum errorType

This enum contains all the different error codes that are possible (in alphabetical order). Whenever an error is thrown, it has to be assigned one of these values. There is also type UNKNOWN for unspecified errors.

Enumerator
ALL_NOT_ALLOWED 

keyword ALL is not allowed for this variable

CAN_ONLY_BE_CALLED_IN_MODE 

function can only be called in certain mode

CAN_ONLY_BE_CALLED_IN_STATE 

function can only be called in certain state

CANNOT_BE_CALLED_IN_MODE 

function cannot be called in certain mode

CANNOT_BE_CALLED_IN_STATE 

function cannot be called in certain state

CANNOT_BE_CONN_SYN_AND_COMP 

cannot be both synaptically and compartmentally connected

CANNOT_BE_CONN_TWICE 

cannot be connected twice

CANNOT_BE_IDENTICAL 

parameters cannot be identical

CANNOT_BE_NEGATIVE 

parameter cannot have negative value (opposite to "must be", but includes zero)

CANNOT_BE_NULL 

parameter cannot have NULL value

CANNOT_BE_LARGER 

parameter cannot have larger vaule than some vaule

CANNOT_BE_SMALLER 

parameter cannot have smaller vaule than some vaule

CANNOT_BE_OFF 

parameter cannot be off

CANNOT_BE_ON 

parameter cannot be on

CANNOT_BE_POSITIVE 

parameter cannot have positive value (opposite to "must be", but includes zero)

CANNOT_BE_SET_TO 

parameter cannot be set to

CANNOT_BE_UNKNOWN 

parameter cannot be of type UNKNOWN

CANNOT_BE_ZERO 

parameter cannot be zero

FILE_CANNOT_CREATE 

could not create a file

FILE_CANNOT_OPEN 

could not open file

IS_DEPRECATED 

deprecated function

MUST_BE_CALLED 

must be called

MUST_BE_IDENTICAL 

parameters must be identical

MUST_BE_IN_RANGE 

parameter must be in some range

MUST_BE_LOGGER_CUSTOM 

must be in custom logger mode

MUST_BE_NEGATIVE 

parameter must have negative value

MUST_BE_OFF 

parameter must be off

MUST_BE_ON 

parameter must be on

MUST_BE_POSITIVE 

parameter must have positive value

MUST_BE_SET_TO 

parameter must be set to

MUST_BE_LARGER 

parameter must be larger than

MUST_BE_SMALLER 

parameter must be smaller than

MUST_BE_ZERO 

parameter must be 0

MUST_HAVE_SAME_SIGN 

some parameters must have the same sign

NETWORK_ALREADY_RUN 

function cannot be called because network has already bun run

UNKNOWN_GROUP_ID 

the specified group id is unknown

UNKNOWN 

an unknown error

WRONG_NEURON_TYPE 

function cannot be applied to neuron type

Definition at line 24 of file user_errors.h.

Member Function Documentation

static void assertFalse ( bool  statement,
errorType  errorIfAssertionFails,
const std::string &  errorFunc,
const std::string &  errorMsgPrefix = "",
const std::string &  errorMsgSuffix = "" 
)
static

This function evaluates a certain statement to true or false. If the statement is false, everything is fine. But, if the statement is true, the function will throw an error and the simulation will abort. There is a standard error message for each user error type. This message can be extended by using a prefix and/or a suffix. For example: errorIfAssertionFails=CANNOT_BE_IDENTICAL, errorMsgPrefix="A", errorMsgSuffix="B" will print "A cannot be identical to B.".

Parameters
[in]statementthe logical statement to evaluate
[in]errorIfAssertionFailsthe type of error to throw if assertion fails (from enum errorType)
[in]errorFunca string to indicate the location where the error occured
[in]errorMsgPrefixa prefix for the error message
[in]errorMsgSuffixa suffix for the error message
static void assertTrue ( bool  statement,
errorType  errorIfAssertionFails,
const std::string &  errorFunc,
const std::string &  errorMsgPrefix = "",
const std::string &  errorMsgSuffix = "" 
)
static

This function evaluates a certain statement to true or false. If the statement is true, everything is fine. But, if the statement is false, the function will throw an error and the simulation will abort. There is a standard error message for each user error type. This message can be extended by using a prefix and/or a suffix. For example: errorIfAssertionFails=CANNOT_BE_IDENTICAL, errorMsgPrefix="A", errorMsgSuffix="B" will print "A cannot be identical to B.".

Parameters
[in]statementthe logical statement to evaluate
[in]errorIfAssertionFailsthe type of error to throw if assertion fails (from enum errorType)
[in]errorFunca string to indicate the location where the error occured
[in]errorMsgPrefixa prefix for the error message
[in]errorMsgSuffixa suffix for the error message

The documentation for this class was generated from the following file: