| 50 | } |
| 51 | |
| 52 | _handleError(error, operationType) { |
| 53 | if (error.response) { |
| 54 | // The request was made and the server responded with a status code |
| 55 | // that falls out of the range of 2xx |
| 56 | const contents = error.response.data |
| 57 | throw new CustomError(contents.name || 'BuildError', contents.originalError, contents.extra) |
| 58 | } else if (error.request) { |
| 59 | // The request was made but no response was received |
| 60 | // `error.request` is an instance of XMLHttpRequest in the browser and an instance of |
| 61 | // http.ClientRequest in node.js |
| 62 | debug('No response received from build server. Is the server down?') |
| 63 | throw new CustomError('BuildError', { |
| 64 | operation: operationType, |
| 65 | reason: 'BUILD_SERVICE_UNREACHABLE', |
| 66 | url: error.request._currentUrl, |
| 67 | }) |
| 68 | } else { |
| 69 | // Something happened in setting up the request that triggered an Error |
| 70 | throw new CustomError('BuildError', error.message, { operation: operationType }) |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | async getPackageBuildStats(packageString, priority) { |
| 75 | return await requestQueue.process( |