Skip to content

Instantly share code, notes, and snippets.

@theboreddev
Last active October 24, 2021 08:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theboreddev/db50fd8c3f1474a5d9f822a8e32456cb to your computer and use it in GitHub Desktop.
Save theboreddev/db50fd8c3f1474a5d9f822a8e32456cb to your computer and use it in GitHub Desktop.
throwing exception
fun findEmployeeByName(name: String): Employee {
val request = Request(Method.GET, "http://myservice.org/employees").query("name", name)
val response: Response = client(request)
if (response.status == Status.OK) {
return Employee(response.bodyString())
}
throw RuntimeException("Could not find employee $name!")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment