All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.solab.alarms.scala.bindings.scala Maven / Gradle / Ivy

There is a newer version: 1.7.2
Show newest version
package com.solab.alarms.scala

import com.solab.alarms.AlarmSender

/*
The "bindings" object offers an implicit conversion to create a ScalarmSender containing an AlarmSender, so that the "withAlarm" functions
can be easily used within Scala code.
*/
object bindings {

	implicit def bindAlarmSender(sender:AlarmSender) = new ScalarmSender(sender)

}

class ScalarmSender(sender:AlarmSender) {

	def withAlarm(alarm:String, source:String)(body: => Unit) {
		try {
			body
		} catch {
			case e:Exception =>
				sender.sendAlarm(alarm, source)
				throw e
		}
	}

	def withAlarm(alarm:String)(body: => Unit) {
		try {
			body
		} catch {
			case e:Exception =>
				sender sendAlarm alarm
				throw e
		}
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy