Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Refine job errors #839

Conversation

Gerhut
Copy link
Member

@Gerhut Gerhut commented Jul 9, 2018

@Gerhut Gerhut requested review from hwuu, wangcan0329 and abuccts July 9, 2018 10:05
@Gerhut Gerhut force-pushed the qixcheng/rest-server-refine-error/job branch from ae96521 to 1f7a092 Compare July 9, 2018 10:06
@coveralls
Copy link

coveralls commented Jul 9, 2018

Coverage Status

Coverage decreased (-17.9%) to 51.39% when pulling 1c05d72 on qixcheng/rest-server-refine-error/job into 06578ef on qixcheng/rest-server-refine-error/vc.

@coveralls
Copy link

Coverage Status

Coverage decreased (-10.7%) to 61.473% when pulling 1f7a092 on qixcheng/rest-server-refine-error/job into 515aa90 on qixcheng/rest-server-refine-error/vc.

@Gerhut Gerhut force-pushed the qixcheng/rest-server-refine-error/vc branch from 515aa90 to 9a81cda Compare July 9, 2018 14:29
@Gerhut Gerhut force-pushed the qixcheng/rest-server-refine-error/job branch from 1f7a092 to 7d09142 Compare July 9, 2018 14:30
error: 'JobNotFound',
message: `could not find job ${jobName}`,
});
return next(error);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error --> createError(...) ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this error has code property in this branch, assume that it has been already transformed into HttpError in utils/error.js

} else if (jobList === undefined) {
// Unreachable
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If these lines are unreachable, why do we still preserve them?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Gerhut only refined error handling in this PR.

message: err.message,
});
}
return next(createError.unknown(err));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think your method covers too many details.

Copy link
Contributor

@hwuu hwuu Jul 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest we split errors into two categories:

  • Internal errors, which are raised by models and handled by controllers;
  • Exposed errors, which will be returned to API callers.

Errors in the first category contain many infrastructure-specific details, for example HDFS error, launcher error, VC error, Yarn error, token error, etc., which are not necessary to be exposed to API callers. After the processed by controllers, these internal errors will eventually be reorganized and translated into exposed errors, which contain meaningful information relevant to the knowledge of external developers, who care more about higher-level concepts such as input syntax, storage, computational resource status, authentication, etc.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think those errors have been handled in models instead of here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@abuccts abuccts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine to me. Pls do not merge until @hwuu approved.

@@ -119,9 +123,9 @@ class Job {
if (requestRes.status === 200) {
next(this.generateJobDetail(requestResJson), null);
} else if (requestRes.status === 404) {
next(null, new Error('JobNotFound'));
next(null, createError('Not Found', 'ERR_NO_JOB', `Job ${name} not found.`));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move error to the first parameter?

message: err.message,
});
}
return next(createError.unknown(err));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think those errors have been handled in models instead of here.

@Gerhut Gerhut force-pushed the qixcheng/rest-server-refine-error/vc branch from df3f1d9 to 06578ef Compare July 13, 2018 01:23
@Gerhut Gerhut force-pushed the qixcheng/rest-server-refine-error/job branch from 1bbdb47 to 4a4b087 Compare July 13, 2018 01:30
@Gerhut Gerhut force-pushed the qixcheng/rest-server-refine-error/job branch from 4a4b087 to 1c05d72 Compare July 13, 2018 01:53
@Gerhut
Copy link
Member Author

Gerhut commented Jul 13, 2018

#807 (comment)

@Gerhut Gerhut merged commit 3c5c1d0 into qixcheng/rest-server-refine-error/vc Jul 18, 2018
Gerhut added a commit that referenced this pull request Jul 19, 2018
* Refine job errors

* Add test cases

* REST Server: Rename error codes according to the Mirosoft api-guideline
Gerhut added a commit that referenced this pull request Jul 19, 2018
* Refine job errors

* Add test cases

* REST Server: Rename error codes according to the Mirosoft api-guideline
@Gerhut Gerhut deleted the qixcheng/rest-server-refine-error/job branch July 24, 2018 06:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants