Created
December 11, 2020 19:34
-
-
Save imnotbob/7ddca07de3514a96f8926808660deb96 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
*/ | |
import groovy.transform.Field | |
definition( | |
name: "test Exceptions", | |
namespace: "ttt", | |
author: "ttt", | |
description: "test exceptions", | |
category: "My Apps", | |
iconUrl: "https://raw.githubusercontent.com/tonesto7/echo-speaks/master/resources/icons/es_actions.png", | |
iconX2Url: "https://raw.githubusercontent.com/tonesto7/echo-speaks/master/resources/icons/es_actions.png", | |
iconX3Url: "https://raw.githubusercontent.com/tonesto7/echo-speaks/master/resources/icons/es_actions.png", | |
importUrl : "https://raw.githubusercontent.com/tonesto7/echo-speaks/master/smartapps/tonesto7/echo-speaks-actions.src/echo-speaks-actions.groovy", | |
pausable: true) | |
preferences { | |
page(name: "startPage") | |
page(name: "uhOhPage") | |
page(name: "mainPage") | |
} | |
void installed() { | |
} | |
void updated() {} | |
def startPage() { | |
mainPage() | |
} | |
def uhOhPage () { | |
return dynamicPage(name: "uhOhPage", title: "This install Method is Not Allowed", install: false, uninstall: true) { | |
section() { | |
paragraph "HOUSTON WE HAVE A PROBLEM!", required: true, | |
state: null, image: getAppImg("exclude") | |
} | |
} | |
} | |
def mainPage() { | |
Boolean newInstall = (state?.isInstalled != true) | |
return dynamicPage(name: "mainPage", nextPage: "", uninstall: true, install: true) { | |
section(sTS("exception without try/catch")) { | |
input "nocatch", "bool", title: inTS("No try/catch", getAppImg("list", true)), description: "", defaultValue: false, submitOnChange: true, image: getAppImg("list") | |
} | |
if(nocatch) { | |
settingUpdate("nocatch", "false", "bool") | |
withoutcatch() | |
} | |
section(sTS("with Try/catch")) { | |
input "catchIt", "bool", title: inTS("With catch?", getAppImg("pause_orange", true)), defaultValue: false, submitOnChange: true, image: getAppImg("pause_orange") | |
} | |
if(catchIt) { | |
settingUpdate("catchIt", "false", "bool") | |
withcatch() | |
} | |
} | |
} | |
void settingUpdate(name, value, type=null) { | |
if(name && type) { app?.updateSetting("$name", [type: "$type", value: value]) } | |
else if (name && type == null) { app?.updateSetting(name.toString(), value) } | |
} | |
void withoutcatch() { | |
Map b | |
if (b.c.d) { log.warn "b.c.d" } | |
} | |
void withcatch() { | |
withcatch1() | |
} | |
void withcatch1() { | |
try{ | |
Map b | |
if (b.c.d) { log.warn "b.c.d" } | |
} catch (ex) { | |
log.warn " NESTED (NO LINE NUMBER) caught: ${ex}" | |
} | |
} | |
String getAppImg(String imgName, frc=false) { return (frc || isStFLD) ? "https://raw.githubusercontent.com/tonesto7/echo-speaks/master/resources/icons/${imgName}.png" : "" } | |
String getPublicImg(String imgName) { return isStFLD ? "https://raw.githubusercontent.com/tonesto7/SmartThings-tonesto7-public/master/resources/icons/${imgName}.png" : "" } | |
String sTS(String t, String i = null, bold=false) { return isStFLD ? t : """<h3>${i ? """<img src="${i}" width="42"> """ : ""} ${bold ? "<b>" : ""}${t?.replaceAll("\\n", "<br>")}${bold ? "</b>" : ""}</h3>""" } | |
/* """ */ | |
String inTS(String t, String i = null, color=null, under=true) { return isStFLD ? t : """${color ? """<div style="color: $color;">""" : ""}${i ? """<img src="${i}" width="42"> """ : ""} ${under ? "<u>" : ""}${t?.replaceAll("\\n", " ")}${under ? "</u>" : ""}${color ? "</div>" : ""}""" } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment