Skip to content

Commit

Permalink
Fix builtin exceptions in Scenario service
Browse files Browse the repository at this point in the history
  • Loading branch information
remyhaemmerle-da committed May 21, 2021
1 parent fc4c0fb commit 852de80
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

-- @SINCE-LF-FEATURE DAML_EXCEPTIONS
-- @ERROR range=130:1-130:23; Unhandled exception: ExceptionSemantics:E
-- @ERROR range=145:1-145:25; CRASH: ArithmeticError while evaluating DIV_INT64(1,0).
-- @ERROR range=145:1-145:25; Unhandled exception: ArithmeticError while evaluating (DIV_INT64 1 0).
-- @ERROR range=182:1-182:11; Attempt to exercise a consumed contract
module ExceptionSemantics where

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,9 @@ prettyScenarioErrorError (Just err) = do
case err of
ScenarioErrorErrorCrash reason -> pure $ text "CRASH:" <-> ltext reason
ScenarioErrorErrorUserError reason -> pure $ text "Aborted: " <-> ltext reason
ScenarioErrorErrorUnhandledException (ValueGeneralError reason) -> pure $ text "Aborted: " <-> ltext reason
ScenarioErrorErrorUnhandledException exc -> pure $ text "Unhandled exception: " <-> prettyValue' True 0 world exc
ScenarioErrorErrorUnhandledBuiltinException reason -> pure $ text $ "Unhandled exception: " <> TL.toStrict reason
ScenarioErrorErrorUnhandledUserException (ValueGeneralError reason) -> pure $ text "Aborted: " <-> ltext reason
ScenarioErrorErrorUnhandledUserException exc -> pure $ text "Unhandled exception: " <-> prettyValue' True 0 world exc
ScenarioErrorErrorTemplatePrecondViolated ScenarioError_TemplatePreconditionViolated{..} -> do
pure $
"Template precondition violated in:"
Expand Down
5 changes: 3 additions & 2 deletions compiler/scenario-service/protos/scenario_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,9 @@ message ScenarioError {
// Error was raised via the error builtin
string user_error = 13;

// Unhandled exception
Value unhandled_exception = 26;
// Unhandled exceptions
string unhandled_builtin_exception = 26;
Value unhandled_user_exception = 27;

// Errors related to update interpretation.
TemplatePreconditionViolated template_precond_violated = 14;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,10 @@ final class Conversions(
setCrash(reason)
case SError.DamlEUnhandledException(exc) =>
exc match {
case SValue.SAnyException(_, sValue) =>
builder.setUnhandledException(convertValue(sValue.toValue))
case error: SValue.SBuiltinException =>
// TODO https://github.com/digital-asset/daml/issues/8020
// We should not crash here.
// We however need conversion primitive for builtin exeception to be implemented.
setCrash(error.message)
builder.setUnhandledBuiltinException(error.message)
case SValue.SAnyException(_, sValue) =>
builder.setUnhandledUserException(convertValue(sValue.toValue))
}
case SError.DamlEUserError(msg) =>
builder.setUserError(msg)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,4 +387,6 @@ final case class NodeId(index: Int)
object NodeId {
implicit def cidMapperInstance[In, Out]: CidMapper[NodeId, NodeId, In, Out] =
CidMapper.trivialMapper

def cidMapperInstance[In, Out] = CidMapper.trivialMapper[Nothing, In, Out]
}

0 comments on commit 852de80

Please sign in to comment.