简体   繁体   中英

How to check github API is unable to connected to github

Is there any way to check from github api that its unable to connect to github or internet is not connected so when i initialize the api by this :

GitHubApi = require("github"); github = new GitHubApi({ version: "3.0.0" });

it should tell by handled exception that unable to connect to github or internet not connected to allow me to stop using other operations of this API. as currently i am getting this exception.

2//Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:118 [Extension Host] Error: getaddrinfo ENOTFOUND api.github.com api.github.com:443
    at global.sendError (/Users/fronteed/.vscode/extensions/Shan.code-settings-sync-2.2.3/node_modules/github/lib/index.js:783:19)
    at /Users/fronteed/.vscode/extensions/Shan.code-settings-sync-2.2.3/node_modules/github/lib/index.js:792:29
    at callCallback (/Users/fronteed/.vscode/extensions/Shan.code-settings-sync-2.2.3/node_modules/github/lib/index.js:667:17)
    at ClientRequest.<anonymous> (/Users/fronteed/.vscode/extensions/Shan.code-settings-sync-2.2.3/node_modules/github/lib/index.js:739:17)
    at emitOne (events.js:90:13)
    at ClientRequest.emit (events.js:182:7)
    at TLSSocket.socketErrorListener (_http_client.js:295:9)
    at emitOne (events.js:90:13)
    at TLSSocket.emit (events.js:182:7)
    at connectErrorNT (net.js:996:8)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)(anonymous function) @ //Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:118 //Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:93 Error Logged In Console (Help menu > Toggle Developer Tools). You may open an issue using 'Sync : Open Issue' from advance setting command.

I have checked an exception to check

 if (error.code == 500) {
            message = "Sync : Internet Not Connected or Unable to Connect to Github. Exception Logged in Console";
            msgBox = false;
        }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM