Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7511711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T23:38:05+00:00 2026-05-29T23:38:05+00:00

The following code demonstrates a case where a checked exception, ExecutionException , is thrown

  • 0

The following code demonstrates a case where a checked exception, ExecutionException, is thrown by an operation and Clojure is wrapping it with RuntimeException.

Why is Clojure doing this? Is this normal? Clojure appears to be doing something different than Java would in this case. What is the idiomatic way to handle the actual exception, in this case Exception, that caused the failure?

user=> (def f (future (Thread/sleep 10000) (throw (Exception. "hello world"))))
#'user/f

user=> (.get f)
Exception hello world  user/fn--318 (NO_SOURCE_FILE:81)

user=> (.printStackTrace *e)
java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.Exception: hello world
    at clojure.lang.Util.runtimeException(Util.java:165)
    at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:97)
    at clojure.lang.Reflector.invokeNoArgInstanceMember(Reflector.java:316)
    at user$eval320.invoke(NO_SOURCE_FILE:82)
    at clojure.lang.Compiler.eval(Compiler.java:6465)
    at clojure.lang.Compiler.eval(Compiler.java:6431)
    at clojure.core$eval.invoke(core.clj:2795)
    at clojure.main$repl$read_eval_print__5967.invoke(main.clj:244)
    at clojure.main$repl$fn__5972.invoke(main.clj:265)
    at clojure.main$repl.doInvoke(main.clj:265)
    at clojure.lang.RestFn.invoke(RestFn.java:421)
    at clojure.main$repl_opt.invoke(main.clj:331)
    at clojure.main$main.doInvoke(main.clj:427)
    at clojure.lang.RestFn.invoke(RestFn.java:397)
    at clojure.lang.Var.invoke(Var.java:397)
    at clojure.lang.AFn.applyToHelper(AFn.java:159)
    at clojure.lang.Var.applyTo(Var.java:518)
    at clojure.main.main(main.java:37)
Caused by: java.util.concurrent.ExecutionException: java.lang.Exception: hello world
    at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:222)
    at java.util.concurrent.FutureTask.get(FutureTask.java:83)
    at clojure.core$future_call$reify__5684.get(core.clj:6064)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:92)
    ... 16 more
Caused by: java.lang.Exception: hello world
    at user$fn__318.invoke(NO_SOURCE_FILE:81)
nil
    at clojure.core$binding_conveyor_fn$fn__3713.invoke(core.clj:1817)
    at clojure.lang.AFn.call(AFn.java:18)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:680)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T23:38:08+00:00Added an answer on May 29, 2026 at 11:38 pm

    According to this link it seems clojure does not throw checked exceptions so I would assume clojure catches any that might be thrown and wraps it:
    http://dev.clojure.org/display/doc/1.3

    As for handling it idiomatically(?) in Java, then the old rules still apply. I would check if the exception wrapped in the ExecutionException was one of the checked exceptions I expected could happen, and handle them as I would in any other circumstance (read: emulate the otherwise compiler enforced try catch). If it wasnt, I would either wrap it in a runtime exception and throw it again or log it and swallow it depending on the situation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following code demonstrates a weird problem I have in a Turbo C++ Explorer
The following code demonstrates a misleading situation in which data is committed to the
For the following code fragment. /*This program demonstartes how a virtual table pointer *
This question is inspired by this question , which features the following code snippet.
The following code demonstrates that the subclass named SubClass has a direct access to
Consider the following code, the first demonstrates that the cleanup executes when we're finished
The following code demonstrates my problem. Running it gives me the error message that
I have the following situation. This is a code snippet, edited to demonstrate the
The following code demonstrates my question: public class DynamicExample { public void DoSomething() {
The following code demonstrates my dilemma. The code creates a background thread which processes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.