Skip to content

Commit

Permalink
Improve error reporting (#2658) [ci fast]
Browse files Browse the repository at this point in the history
Closes #2627

Signed-off-by: Jorge Aguilera <jorge.aguilera@seqera.io>
Signed-off-by: Paolo Di Tommaso <paolo.ditommaso@gmail.com>

Co-authored-by: Paolo Di Tommaso <paolo.ditommaso@gmail.com>
  • Loading branch information
jorgeaguileraseqera and pditommaso committed Apr 23, 2022
1 parent 1e008f4 commit e6ef017
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,10 @@ class ProcessDef extends BindableDef implements IterableDef, ChainableDef {
ProcessConfig getProcessConfig() { processConfig }

ChannelOut getOut() {
if(!output) throw new ScriptRuntimeException("Access to '${processName}.out' is undefined since process doesn't declare any output")
if( output==null )
throw new ScriptRuntimeException("Access to '${processName}.out' is undefined since the process '$processName' has not been invoked before accessing the output attribute")
if( output.size()==0 )
throw new ScriptRuntimeException("Access to '${processName}.out' is undefined since the process '$processName' doesn't declare any output")
return output
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@ class WorkflowDef extends BindableDef implements ChainableDef, IterableDef, Exec
WorkflowBinding getBinding() { binding }

ChannelOut getOut() {
if(!output) throw new ScriptRuntimeException("Access to '${name}.out' is undefined since workflow doesn't declare any output")
if( output==null )
throw new ScriptRuntimeException("Access to '${name}.out' is undefined since the workflow '$name' has not been invoked before accessing the output attribute")
if( output.size()==0 )
throw new ScriptRuntimeException("Access to '${name}.out' is undefined since the workflow '$name' doesn't declare any output")

return output
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ class ScriptDslTest extends Dsl2Spec {

then:
def err = thrown(ScriptRuntimeException)
err.message == "Access to 'foo.out' is undefined since process doesn't declare any output"
err.message == "Access to 'foo.out' is undefined since the process 'foo' has not been invoked before accessing the output attribute"
}

def 'should report error accessing undefined out/b' () {
Expand All @@ -403,7 +403,7 @@ class ScriptDslTest extends Dsl2Spec {

then:
def err = thrown(ScriptRuntimeException)
err.message == "Access to 'foo.out' is undefined since process doesn't declare any output"
err.message == "Access to 'foo.out' is undefined since the process 'foo' has not been invoked before accessing the output attribute"
}

def 'should report error accessing undefined out/c' () {
Expand All @@ -425,7 +425,7 @@ class ScriptDslTest extends Dsl2Spec {

then:
def err = thrown(ScriptRuntimeException)
err.message == "Access to 'flow1.out' is undefined since workflow doesn't declare any output"
err.message == "Access to 'flow1.out' is undefined since the workflow 'flow1' doesn't declare any output"
}

def 'should report error accessing undefined out/d' () {
Expand Down Expand Up @@ -454,6 +454,26 @@ class ScriptDslTest extends Dsl2Spec {
err.message == "Process `bar` declares 1 input channel but 0 were specified"
}

def 'should report error accessing undefined out/e' () {
when:
dsl_eval('''
process foo {
/echo foo/
}
workflow flow1 {
foo()
}
workflow {
flow1.out.view()
}
''')

then:
def err = thrown(ScriptRuntimeException)
err.message == "Access to 'flow1.out' is undefined since the workflow 'flow1' has not been invoked before accessing the output attribute"
}

def 'should report unsupported error' () {
when:
Expand Down

0 comments on commit e6ef017

Please sign in to comment.