Skip to content

Commit

Permalink
Fix display of unhandled exceptions in the scenario service (#10572)
Browse files Browse the repository at this point in the history
fixes #10570

I’m increasingly convniced, that the future failures here are a
maintenance nightmare and we should switch to Either completely but
not in this PR

changelog_begin
changelog_end
  • Loading branch information
cocreature authored Aug 12, 2021
1 parent 4e1a90d commit c447898
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions compiler/damlc/tests/src/DA/Test/ScriptService.hs
Original file line number Diff line number Diff line change
Expand Up @@ -901,16 +901,25 @@ main =
, " error \"\""
, " catch"
, " (GeneralError _) -> pure ()"
, " choice Fail : ()"
, " controller p"
, " do assert False"
, "test = do"
, " p <- allocateParty \"p\""
, " cid <- submit p $ createCmd (T p)"
, " submit p $ createAndExerciseCmd (Helper p) (C cid)"
, " r <- query @T p"
, " r === [(cid, T p)]"
, " pure ()"
, "unhandledOffLedger = script $ assert False"
, "unhandledOnLedger = script $ do"
, " p <- allocateParty \"p\""
, " submit p $ createAndExerciseCmd (Helper p) Fail"
]
expectScriptSuccess rs (vr "test") $ \r ->
matchRegex r "Active contracts: #0:0\n"
expectScriptFailure rs (vr "unhandledOffLedger") $ \r -> matchRegex r "Unhandled exception"
expectScriptFailure rs (vr "unhandledOnLedger") $ \r -> matchRegex r "Unhandled exception"
]
where
scenarioConfig = SS.defaultScenarioServiceConfig {SS.cnfJvmOptions = ["-Xmx200M"]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ class Context(val contextId: Context.ContextId, languageVersion: LanguageVersion
)
)
case Failure(e: Error) => handleFailure(e)
case Failure(e: Runner.InterpretationError) => {
handleFailure(Error.RunnerException(e.error))
}
case Failure(e: ScriptF.FailedCmd) =>
e.cause match {
case e: Error => handleFailure(e)
Expand Down

0 comments on commit c447898

Please sign in to comment.