Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow throw native Error in beforeSave hook #5064

Merged
merged 1 commit into from
Sep 19, 2018

Conversation

reallyimeric
Copy link
Contributor

No description provided.

@codecov
Copy link

codecov bot commented Sep 19, 2018

Codecov Report

Merging #5064 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5064      +/-   ##
==========================================
+ Coverage   93.75%   93.78%   +0.02%     
==========================================
  Files         122      122              
  Lines        8857     8859       +2     
==========================================
+ Hits         8304     8308       +4     
+ Misses        553      551       -2
Impacted Files Coverage Δ
src/triggers.js 94.31% <100%> (+0.05%) ⬆️
src/RestWrite.js 92.96% <0%> (-0.19%) ⬇️
src/Adapters/Storage/Mongo/MongoStorageAdapter.js 92.25% <0%> (+0.72%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5177d5d...4b211df. Read the comment docs.

@flovilmart
Copy link
Contributor

LGTM! Thanks!

@flovilmart flovilmart merged commit 91f121e into parse-community:master Sep 19, 2018
@reallyimeric reallyimeric deleted the iss5063 branch September 19, 2018 15:43
@reallyimeric
Copy link
Contributor Author

@flovilmart Maybe we should not wrap thrown exception on getResponseObject().error(), or any error thrown in

.then(() => {
const promise = trigger(request);
if (
triggerType === Types.afterSave ||
triggerType === Types.afterDelete
) {
logTriggerAfterHook(
triggerType,
parseObject.className,
parseObject.toJSON(),
auth
);
}
return promise;
})
will be regarded as a hook handler error.

@flovilmart
Copy link
Contributor

I’m not sure I understand what you mean.

@reallyimeric
Copy link
Contributor Author

@flovilmart I mean we should convert whatever user's beforeSave handler throws to a Parse.Error (with Parse.Error.SCRIPT_FAILED) as early as possible, or errors occured in library code (if any),which should be an "internal error", could be regarded as user aborting current save action. Sorry for not stating that clearly.

@flovilmart
Copy link
Contributor

That seems reasonable

@acinader
Copy link
Contributor

this fixes: #5063

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants