Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graceful failure for @LOG that follows @IN #43

Open
chicoreus opened this issue May 26, 2017 · 1 comment
Open

Graceful failure for @LOG that follows @IN #43

chicoreus opened this issue May 26, 2017 · 1 comment

Comments

@chicoreus
Copy link

Naïve use of @log would simply embedd it in an @begin @EnD block where a logging statement occurs, however, @log appears to need to follow an @out annotation, having a bare @log which happens to follow a @in statement results in a not immediately helpful exception:

java.lang.ClassCastException: org.yesworkflow.annotations.In cannot be cast to org.yesworkflow.annotations.Out

Graceful failure in this case with a pertinent error message would help.

To reproduce:

# @BEGIN FilterExcludingMarine 
# @IN TaggedDataRecord         
# @LOG {timestamp} [{loglevel}] ACTOR<{actorname}> ->  [{filterKey}]=[{matchValue}]:{match}. Passing occurrenceID={occurrenceID}    
# @OUT NotMarine
# @END FilterExcludingMarin
@chicoreus
Copy link
Author

Here's a potential fix:

diff --git a/src/main/java/org/yesworkflow/extract/DefaultExtractor.java b/src/main/java/org/yesworkflow/extract/DefaultExtractor.java
index 5e25c66..3bb96c9 100644
--- a/src/main/java/org/yesworkflow/extract/DefaultExtractor.java
+++ b/src/main/java/org/yesworkflow/extract/DefaultExtractor.java
@@ -319,7 +319,11 @@ public class DefaultExtractor implements Extractor {
                                     break;
                     case IN:        annotation = new In(id, sourceId, lineNumber, annotationString);
                                     break;
-                    case LOG:       annotation = new Log(id, sourceId, lineNumber, annotationString, (Out) primaryAnnotation);
+                    case LOG:       try { 
+                                        annotation = new Log(id, sourceId, lineNumber, annotationString, (Out) primaryAnnotation);
+                                    } catch (ClassCastException cce) { 
+                                        throw new YWMarkupException("A LOG annotation must follow an OUT annotation as its primaryAnnotation.");
+                                    }
                                     break;
                     case OUT:       annotation = new Out(id, sourceId, lineNumber, annotationString);
                                     break;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant