Skip to content

Commit

Permalink
add explicit messaging for kernel errors
Browse files Browse the repository at this point in the history
  • Loading branch information
MrArnoldPalmer committed Oct 5, 2022
1 parent 57fcb7a commit 2ca6739
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 0 additions & 2 deletions packages/@jsii/go-runtime-test/project/compliance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1536,14 +1536,12 @@ func (i ImplementsStructReturningDelegate) ReturnStruct() *calc.StructB {
}

func (suite *ComplianceSuite) TestExceptions() {
// t := suite.T()
require := suite.Require()

calc3 := calc.NewCalculator(&calc.CalculatorProps{InitialValue: jsii.Number(20), MaximumValue: jsii.Number(30)})
calc3.Add(jsii.Number(3))
require.Equal(float64(23), *calc3.Value())

// TODO: should assert the actual error here - not working for some reasons
require.PanicsWithError("Error: Operation 33 exceeded maximum value 30", func() {
calc3.Add(jsii.Number(10))
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,11 @@ func (p *Process) readResponse(into interface{}) error {
var errResp ErrorResponse
if _, ok := respmap["error"]; ok {
json.Unmarshal(raw, &errResp)

if errResp.Name != nil && *errResp.Name == "@jsii/kernel.Fault" {
return fmt.Errorf("JsiiError: %s", *errResp.Name)
}

return errors.New(errResp.Error)
}

Expand Down

0 comments on commit 2ca6739

Please sign in to comment.