Last change
on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 4 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
859 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | const {
|
---|
| 2 | GitConnectionError,
|
---|
| 3 | GitPathspecError,
|
---|
| 4 | GitUnknownError
|
---|
| 5 | } = require('./errors.js')
|
---|
| 6 |
|
---|
| 7 | const 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 |
|
---|
| 18 | const missingPathspecRe = /pathspec .* did not match any file\(s\) known to git/
|
---|
| 19 |
|
---|
| 20 | function 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 |
|
---|
| 33 | module.exports = makeError
|
---|
Note:
See
TracBrowser
for help on using the repository browser.