source: trip-planner-front/node_modules/@npmcli/git/lib/make-error.js@ 6a3a178

Last change on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 859 bytes
Line 
1const {
2 GitConnectionError,
3 GitPathspecError,
4 GitUnknownError
5} = require('./errors.js')
6
7const connectionErrorRe = new RegExp([
8 'remote error: Internal Server Error',
9 'The remote end hung up unexpectedly',
10 'Connection timed out',
11 'Operation timed out',
12 'Failed to connect to .* Timed out',
13 'Connection reset by peer',
14 'SSL_ERROR_SYSCALL',
15 'The requested URL returned error: 503'
16].join('|'))
17
18const missingPathspecRe = /pathspec .* did not match any file\(s\) known to git/
19
20function makeError (er) {
21 const message = er.stderr
22 let gitEr
23 if (connectionErrorRe.test(message)) {
24 gitEr = new GitConnectionError(message)
25 } else if (missingPathspecRe.test(message)) {
26 gitEr = new GitPathspecError(message)
27 } else {
28 gitEr = new GitUnknownError(message)
29 }
30 return Object.assign(gitEr, er)
31}
32
33module.exports = makeError
Note: See TracBrowser for help on using the repository browser.