1
0
-1

Hello.

i externalized scripts and so far it works. I like to externalize a validation script which can throw an exception. But when this scripts should throws the exception, nothing happens: "throw new IssueTrackerException(message)"
The exception does not stop the synchronisation. (but i can see the message in the log which my script produces )
What do i do wrong?


Cheers Adrian
Adrian

---------------------------------------------------------
Incoming Rules:

Validate_IssueTypes.validate(issue, replica, connection)

// Core Field Mappings
issue.project = replica.project
issue.type = replica.type
issue.status = replica.status

SyncField_Summary.receive(issue, replica)
SyncField_Description.receive(issue, replica)
SyncField_Comment.receive(issue, replica, commentHelper)

---------------------------------------------------------
Script :

import org.slf4j.Logger
import com.exalate.api.exception.IssueTrackerException

class Validate_IssueTypes {

static validate(issue, replica, connection) {
String message
def allowedIssueTypes = ['Task', 'Story', 'Bug']
def log = org.slf4j.LoggerFactory.getLogger("com.exalate")

if (!allowedIssueTypes.contains(replica.type.name)) {
message = "Assert Issue-Types | " +
"Connection = '" + connection.name + "' | " +
"Rule = 'ruleName' | " +
"Issue-Type = '" + replica.type.name + "' is not allowed. " +
"The issue with key '" + replica.key + "' will not be synchronized to hosting-zone. " +
"Check the trigger, the issue type should be excluded from synch trigger !"
log.error(message)
throw new IssueTrackerException(message)
}
}
}

  1. Serhiy Onyshchenko

    Hello, Adrian Suter, what happens if you wrap the entire Incoming rules with a 

    try {   // ... incoming rules} catch (Exception e) {  log.error("#caught it!", e);  throw e;
    }

    Regards, Serhiy.

CommentAdd your comment...

1 answer

  1.  
    1
    0
    -1

    Hello Serhiy,


    That worked, thanks very much.  Now the synch wont't happen and i get the message of the exception in teh Exalate error console as expected:

    ----------------------------------------------------------------------------------------------------

    Error Detail Message:

    Script error details: Assert Issue-Types | Connection = 'BasicField_Sync' | Rule = 'ruleName' | Issue-Type = 'NixIssueType' is not allowed. The issue with key 'TESTBASY-19' will not be synchronized to hosting-zone. Check the trigger, the issue type should be excluded from synch trigger !. Error line: Validate_IssueTypes.groovy:19

    ------------------------------------------------------------------------------------------------------


    Another question about exceptions. When i read "Script error details:" and "Error line: Validate_IssueTypes.groovy:19" it seems for me, like the script it self had an error. Are there any other Exalate exceptions i should take ? Are there any links to the documentation ?


    Cheers Adrian


      CommentAdd your comment...