Implemented IsgdException. Closes #1

This commit is contained in:
Erik C. Thauvin 2021-06-05 12:39:58 -07:00
parent 5b64333e8a
commit a55fddb77b
9 changed files with 136 additions and 15 deletions

View file

@ -1,15 +1,20 @@
package com.example;
import net.thauvin.erik.isgd.Isgd;
import net.thauvin.erik.isgd.IsgdException;
public final class IsgdSample {
public static void main(final String[] args) {
if (args.length > 0) {
for (final String arg : args) {
if (arg.contains("is.gd")) {
System.out.println(arg + " <-- " + Isgd.lookup(arg));
} else {
System.out.println(arg + " --> " + Isgd.shorten(arg));
try {
if (arg.contains("is.gd")) {
System.out.println(arg + " <-- " + Isgd.lookup(arg));
} else {
System.out.println(arg + " --> " + Isgd.shorten(arg));
}
} catch (IsgdException e) {
System.out.println(e.getMessage());
}
}
} else {

View file

@ -1,15 +1,20 @@
package com.example
import net.thauvin.erik.isgd.Isgd
import net.thauvin.erik.isgd.IsgdException
import kotlin.system.exitProcess
fun main(args: Array<String>) {
if (args.isNotEmpty()) {
args.forEach {
if (it.contains("is.gd"))
println(it + " <-- " + Isgd.lookup(it))
else
println(it + " --> " + Isgd.shorten(it))
try {
if (it.contains("is.gd"))
println(it + " <-- " + Isgd.lookup(it))
else
println(it + " --> " + Isgd.shorten(it))
} catch (e: IsgdException) {
println(e.message)
}
}
} else {
println("Try specifying one or more URLs as arguments.")