MemberJunction / MJ

Main MemberJunction Repository
https://docs.memberjunction.org/
ISC License
4 stars 0 forks source link

Update return type of BaseEntity.Save and Delete functions from a boolean to EntityTransactionResultType #246

Closed JS-BC closed 2 months ago

JS-BC commented 4 months ago

Purpose: In the future, we want to add the ability to display error messages to a user if a save attempt fails (https://github.com/MemberJunction/MJ/issues/243). Currently, if a save attempt fails due to validation errors, an exception is thrown containing reasons why, i.e. Validation Error Messages. Rather than wrapping every save attempt client side in a try-catch block, it would be easier for us to get error messages and display them if the save attempt returns an object similar to the RunViewResult type that contains a Success, Result, and ErrorMessages properties.

The EntityTransactionResultType type could be defined as below:

Success: Boolean

ErrorMessages: String[]

ValidationErrorMessages: any[]

WarningMessages: String[]

Thoughts? @AN-BC

AN-BC commented 4 months ago

@JS-BC let's make this "EntityTransactionResultType" instead and that way we can use this for both Save and Delete basically that would cover Create/Update/Delete scenarios, or all transactions.

JS-BC commented 2 months ago

@AN-BC This isnt needed now that we have BaseEntity.LatestResult right?

AN-BC commented 2 months ago

@JS-BC yup - that's right, I'm closing this issue. Thanks.