Home » Modeling » M2T (model-to-text transformation) » [Acceleo] template/generation error listening(other than watching STDOUT)
[Acceleo] template/generation error listening [message #917733] |
Thu, 20 September 2012 07:30  |
Eclipse User |
|
|
|
I have a relatively large Acceleo component that functions as a Maven plugin. It's pretty useful, but one of the things that would make it better is having my Maven build fail if generation raises exceptions.
For example,
org.eclipse.acceleo.engine.AcceleoEvaluationException: Invalid loop iteration at line 46 in Module java for block for (getOwnedContraintInPackage(ownedAttribute,Bag {'constraints'})). Last recorded value of self was org.eclipse.uml2.uml.internal.impl.PropertyImpl@484d3500 (name: searchTerm, visibility: <unset>) (isLeaf: false) (isStatic: false) (isOrdered: false, isUnique: true, isReadOnly: false) (isDerived: false, isDerivedUnion: false, aggregation: none). Problem found while generating the file 'D:\Projects\whatever-proxy\target\generated-sources\java\com\whatever\forms\SomethingSearchForm.java'.
at java.generateValidationConstraints(Property)(java.mtl:46)
at java.generateValidationConstraints(Property)(java.mtl:45)
turns up in my STDOUT, and is definitely a failure. However, I can't find a way to listen for this happening - no exception gets thrown to or by my Generate class, which I'm wrapping in the Maven task.
Monitor and IAcceleoTextGenerationListener do not seem to have quite the capacity I want, though it's entirely possible I'm reading the API wrong.
How can I listen for these kinds of event?
[Updated on: Thu, 20 September 2012 11:19] by Moderator
|
|
| | | | |
Re: [Acceleo] template/generation error listening [message #1005979 is a reply to message #1005938] |
Tue, 29 January 2013 08:15   |
Eclipse User |
|
|
|
Since AcceleoService is final, and its methods are mostly private anyway, my choices become
1. Fork Acceleo (I don't like this idea much) and alter AcceleoService directly, or
2. have my Generate class use something that is almost exactly an AcceleoService in terms of function and code, but isn't an AcceleoService (in the OO sense).
Neither of these is wonderful, given that there has been helpful effort in Acceleo to provide interfaces like IAcceleoEngine and AbstractGenerator and so on to allow extensibility. But I will do the second one
Out of interest, why is AcceleoService final?
[edit: looking at it, my idea won't work; too many parts of the Acceleo code take an AcceleoService argument explicitly when they are called from Generate. Hmm. Alternatively I can have just the parts of Generate that call AcceleoService, which in turn delegates to the Engine, do... something different.]
[Updated on: Tue, 29 January 2013 08:31] by Moderator
|
|
|
Re: [Acceleo] template/generation error listening [message #1009510 is a reply to message #1005979] |
Fri, 15 February 2013 03:56   |
Eclipse User |
|
|
|
Joel,
Within Eclipse, you can locate the LogView and add log listeners to react to them.
Outside of Eclipse, we log errors on System.err (http://git.eclipse.org/c/m2t/org.eclipse.acceleo.git/tree/plugins/org.eclipse.acceleo.engine/src/org/eclipse/acceleo/engine/AcceleoEnginePlugin.java#n73). The exception is not thrown "out" of Acceleo as long as it is not fatal. Furthermore, most exceptions won't even stop the generation. What you pasted in the first post of this thread is an example of such an exception : we failed on one template, but we can still continue to generate for the rest.
AcceleoService is final since it was simply not designed to be extended. This class is only meant as an interface between the client code and the generation engine, in order to avoid rewriting all the boilerplate code. Replacing the engine is something that is rarely necessary, and since it is sufficiently rare, we decided not to spend time trying to make it easier. You will have to copy/paste the "AcceleoService#doGenerate(...)" method that is closest to what you seek to do, and replace the default AcceleoEngine we call by your own instance.
This is something we have never needed to do, and as such some necessary methods may be internal, don't hesistate to raise enhancement requests if you hit a wall .
Laurent Goubet
Obeo
|
|
| |
Re: [Acceleo] template/generation error listening [message #1716061 is a reply to message #1715869] |
Mon, 30 November 2015 17:13  |
Eclipse User |
|
|
|
Hi
Your problem seems nothing to do with the earlier thread, so it is very
difficult to answer.
Generally Java is quite flexible about throwing and catching exceptions,
so what is your problem?
Regards
Ed Willink
On 30/11/2015 20:16, Prashant Gupta wrote:
> Hello,
>
> I am facing similar type of problem. I want to throw any Exception that
> happens in acceleo code template to my Generate class, and through that
> to my calling class, so as I can show error on UI screen.
> But i am unable to find any way to capture those exceptions.
> Pl help.
>
> Thanks in advance.
>
> Prashant Gupta
|
|
|
Goto Forum:
Current Time: Mon May 12 09:01:46 EDT 2025
Powered by FUDForum. Page generated in 0.04776 seconds
|