librelist archives

« back to archive

Catching Errors in Leiningen

Catching Errors in Leiningen

From:
Max Magnuson
Date:
2015-01-30 @ 21:46
Hello,

We are a part of a group with the University of Minnesota, Morris that is
trying to implement Clojure in an introductory CS course. To accomplish
this we would like to modify the existing error messages in Clojure to be
more useful for introductory students. Our current plan is to write a
plugin for Leiningen that would catch exceptions thrown by a student's
project when it is run by Leiningen. We want to then take that exception
and modify the exception and the contents of the message before it is
printed to the console.

 Our plan is to use the Hooke library to insert a try catch that will
modify any error that may be thrown. We would like to know if this plan
sounds reasonable, and where exactly the exceptions that get printed to the
console are handled in Leiningen.

Any help would be greatly appreciated.

Thanks,
Max Magnuson and Henry Fellows

Re: [leiningen] Catching Errors in Leiningen

From:
Phil Hagelberg
Date:
2015-01-31 @ 14:28
Max Magnuson <magnu401@morris.umn.edu> writes:

> Our plan is to use the Hooke library to insert a try catch that will
> modify any error that may be thrown. We would like to know if this plan
> sounds reasonable, and where exactly the exceptions that get printed to the
> console are handled in Leiningen.

You can't do this using Robert Hooke because `throw` is not a var. It's
a special form that's hard-coded into the compiler. It would be possible
to do this with a code-walking macro (like core.async) but it would be a
lot more invasive.

In general Leiningen does not print any exception messages on its
own. Even if it did, exceptions are often caught inside the application
and logged either to standard out or to a file. If you are interested in
only implementing this behaviour in the repl task, you could do that
with an nREPL middleware rather than as a Leiningen plugin.

-Phil

Re: [leiningen] Catching Errors in Leiningen

From:
Colin Fleming
Date:
2015-01-31 @ 02:22
Hi Max and Henry,

Have you taken a look at dynalint <https://github.com/frenchy64/dynalint>
and lein-dynalint <https://github.com/frenchy64/lein-dynalint>? They sound
quite similar to what you're trying to achieve.

Cheers,
Colin

On 31 January 2015 at 10:46, Max Magnuson <magnu401@morris.umn.edu> wrote:

> Hello,
>
> We are a part of a group with the University of Minnesota, Morris that is
> trying to implement Clojure in an introductory CS course. To accomplish
> this we would like to modify the existing error messages in Clojure to be
> more useful for introductory students. Our current plan is to write a
> plugin for Leiningen that would catch exceptions thrown by a student's
> project when it is run by Leiningen. We want to then take that exception
> and modify the exception and the contents of the message before it is
> printed to the console.
>
>  Our plan is to use the Hooke library to insert a try catch that will
> modify any error that may be thrown. We would like to know if this plan
> sounds reasonable, and where exactly the exceptions that get printed to the
> console are handled in Leiningen.
>
> Any help would be greatly appreciated.
>
> Thanks,
> Max Magnuson and Henry Fellows
>