Skip to content

Commit

Permalink
better custom resource exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
kichik committed Apr 29, 2020
1 parent 03b2c79 commit d8c09a6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
10 changes: 7 additions & 3 deletions CloudWatch2S3-additional-account.template
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,13 @@ Resources:

cfnresponse.send(event, context, cfnresponse.SUCCESS, {}, "ok")

except:
traceback.print_last()
cfnresponse.send(event, context, cfnresponse.FAILED, {}, "ok")
except Exception as e:
try:
traceback.print_last()
except ValueError:
print("Caught exception but unable to print stack trace")
print(e)
cfnresponse.send(event, context, cfnresponse.FAILED, {}, "fail")

else:
# other call
Expand Down
10 changes: 7 additions & 3 deletions CloudWatch2S3.template
Original file line number Diff line number Diff line change
Expand Up @@ -689,9 +689,13 @@ Resources:

cfnresponse.send(event, context, cfnresponse.SUCCESS, {}, "ok")

except:
traceback.print_last()
cfnresponse.send(event, context, cfnresponse.FAILED, {}, "ok")
except Exception as e:
try:
traceback.print_last()
except ValueError:
print("Caught exception but unable to print stack trace")
print(e)
cfnresponse.send(event, context, cfnresponse.FAILED, {}, "fail")

else:
# other call
Expand Down

0 comments on commit d8c09a6

Please sign in to comment.