From 5643d3710d42f3efdd15d936fe7ed3f9a555a60f Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Mon, 8 Aug 2016 15:47:35 -0500 Subject: [PATCH] Actually add the exceptions --- includes/exceptions.inc.php | 70 +++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 includes/exceptions.inc.php diff --git a/includes/exceptions.inc.php b/includes/exceptions.inc.php new file mode 100644 index 0000000000..4964c3683b --- /dev/null +++ b/includes/exceptions.inc.php @@ -0,0 +1,70 @@ +. + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Tony Murray + * @author Tony Murray + */ + + +// ---- addHost Excpetions ---- +class HostExistsException extends Exception {} + +class HostIpExistsException extends HostExistsException {} + +class InvalidPortAssocModeException extends Exception {} + +class SnmpVersionUnsupportedException extends Exception {} + +class HostUnreachableException extends Exception +{ + protected $reasons = array(); + + public function __toString() + { + $string = __CLASS__ . ": [{$this->code}]: {$this->message}\n"; + foreach ($this->reasons as $reason) { + $string .= " $reason\n"; + } + return $string; + } + + /** + * Add additional reasons + * @param $message + */ + public function addReason($message) + { + $this->reasons[] = $message; + } + + /** + * Get the reasons + * @return array + */ + public function getReasons() + { + return $this->reasons; + } +} + +class HostUnreachablePingException extends HostUnreachableException {} + +class HostUnreachableSnmpException extends HostUnreachableException {}