core: 调整 Error 参数 (#94)

This commit is contained in:
无限UCW authored and GitHub committed 2021-04-17 22:21:43 +08:00
1 parent 994634947e
commit 71c1226515
7 files changed
+10 -10

No files matched your search

+1 -1
View File
@@ -261,7 +261,7 @@ class ContestProblemHandler extends ContestHandler {
if (contest.isNotStarted(this.tdoc)) throw new ContestNotLiveError(this.tdoc.docId);
}
if (!this.tdoc.pids.map((s) => s.toString()).includes(this.pdoc.docId.toString())) {
throw new ProblemNotFoundError(pid, this.tdoc.docId);
throw new ProblemNotFoundError(domainId, this.tdoc.docId);
}
}
+4 -4
View File
@@ -42,17 +42,17 @@ class DiscussionHandler extends Handler {
this.checkPerm(PERM.PERM_VIEW_DISCUSSION);
if (did) {
this.ddoc = await discussion.get(domainId, did);
if (!this.ddoc) throw new DiscussionNotFoundError(did);
if (!this.ddoc) throw new DiscussionNotFoundError(domainId, did);
type = discussion.typeDisplay[this.ddoc.parentType];
name = this.ddoc.parentId.toString();
if (drrid) {
[this.drdoc, this.drrdoc] = await discussion.getTailReply(domainId, drid, drrid);
if (!this.drrdoc) throw new DiscussionNotFoundError(drrid);
if (!this.drrdoc) throw new DiscussionNotFoundError(domainId, drrid);
} else if (drid) {
this.drdoc = await discussion.getReply(domainId, drid);
if (!this.drdoc) throw new DiscussionNotFoundError(drid);
if (!this.drdoc) throw new DiscussionNotFoundError(domainId, drid);
if (!this.drdoc.parentId.equals(this.ddoc._id)) {
throw new DocumentNotFoundError(drid);
throw new DocumentNotFoundError(domainId, drid);
}
}
}
+1 -1
View File
@@ -510,7 +510,7 @@ export class ProblemSolutionHandler extends ProblemDetailHandler {
@param('content', Types.Content)
async postEditReply(domainId: string, psid: ObjectID, psrid: ObjectID, content: string) {
const [psdoc, psrdoc] = await solution.getReply(domainId, psid, psrid);
if ((!psdoc) || psdoc.pid !== this.pdoc.docId) throw new SolutionNotFoundError(psid);
if ((!psdoc) || psdoc.pid !== this.pdoc.docId) throw new SolutionNotFoundError(domainId, psid);
if (!(psrdoc.owner === this.user._id
&& this.user.hasPerm(PERM.PERM_EDIT_PROBLEM_SOLUTION_REPLY_SELF))) {
throw new PermissionError(PERM.PERM_EDIT_PROBLEM_SOLUTION_REPLY_SELF);