Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
Merge pull request #317 from atom/improve-diagnostics-for-http-reques…
Browse files Browse the repository at this point in the history
…t-errors

Improve diagnostics for package initialization errors
  • Loading branch information
jasonrudolph authored Feb 5, 2018
2 parents dfaecf6 + 7cf8d55 commit d069864
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 9 deletions.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ module.exports = new TeletypePackage({
cluster: atom.config.get('teletype.pusherCluster'),
disableStats: true
},
baseURL: atom.config.get('teletype.baseURL')
baseURL: atom.config.get('teletype.baseURL'),
getAtomVersion: atom.getVersion.bind(atom)
})
27 changes: 25 additions & 2 deletions lib/package-initialization-error-component.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const etch = require('etch')
const {URL} = require('url')
const $ = etch.dom

module.exports =
Expand All @@ -16,7 +17,6 @@ class PackageInitializationErrorComponent {
render () {
return $.div({className: 'PackageInitializationErrorComponent'},
$.h3(null, 'Teletype initialization failed'),
$.p(null, 'Error: ' + this.props.initializationError.message),
$.p(null, 'Make sure your internet connection is working and restart the package.'),
$.div(null,
$.button(
Expand All @@ -31,15 +31,38 @@ class PackageInitializationErrorComponent {
),
$.p(null,
'If the problem persists, visit ',
$.a({href: 'https://github.com/atom/teletype/issues/new', className: 'text-info'}, 'atom/teletype'),
$.a({href: this.getIssueURL(), className: 'text-info'}, 'atom/teletype'),
' and open an issue.'
)
)
}

getIssueURL () {
const {initializationError} = this.props

const url = new URL('https://github.com/atom/teletype/issues/new')
url.searchParams.append('title', 'Package Initialization Error')
url.searchParams.append('body',
'### Diagnostics\n\n' +
'```\n' +
initializationError.diagnosticMessage + '\n\n' +
'```\n' +
'### Versions\n\n' +
`**Teletype version**: v${getTeletypeVersion()}\n` +
`**Atom version**: ${this.props.getAtomVersion()}\n` +
`**Platform**: ${process.platform}\n`
)

return url.href
}

async restartTeletype () {
const {packageManager} = this.props
await packageManager.deactivatePackage('teletype')
await packageManager.activatePackage('teletype')
}
}

function getTeletypeVersion () {
return require('../package.json').version
}
3 changes: 2 additions & 1 deletion lib/popover-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class PopoverComponent {
const {
isClientOutdated, initializationError,
authenticationProvider, portalBindingManager,
commandRegistry, clipboard, workspace, notificationManager, packageManager
commandRegistry, clipboard, workspace, notificationManager, packageManager, getAtomVersion
} = this.props

let activeComponent
Expand All @@ -36,6 +36,7 @@ class PopoverComponent {
activeComponent = $(PackageInitializationErrorComponent, {
ref: 'packageInitializationErrorComponent',
packageManager,
getAtomVersion,
initializationError
})
} else if (this.props.authenticationProvider.isSignedIn()) {
Expand Down
10 changes: 6 additions & 4 deletions lib/teletype-package.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ module.exports =
class TeletypePackage {
constructor (options) {
const {
baseURL, clipboard, commandRegistry, credentialCache, notificationManager,
packageManager, pubSubGateway, pusherKey, pusherOptions,
tetherDisconnectWindow, tooltipManager, workspace
baseURL, clipboard, commandRegistry, credentialCache, getAtomVersion,
notificationManager, packageManager, pubSubGateway, pusherKey,
pusherOptions, tetherDisconnectWindow, tooltipManager, workspace
} = options

this.workspace = workspace
Expand All @@ -24,6 +24,7 @@ class TeletypePackage {
this.pusherKey = pusherKey
this.pusherOptions = pusherOptions
this.baseURL = baseURL
this.getAtomVersion = getAtomVersion
this.tetherDisconnectWindow = tetherDisconnectWindow
this.credentialCache = credentialCache || new CredentialCache()
this.client = new TeletypeClient({
Expand Down Expand Up @@ -132,7 +133,8 @@ class TeletypePackage {
clipboard: this.clipboard,
workspace: this.workspace,
notificationManager: this.notificationManager,
packageManager: this.packageManager
packageManager: this.packageManager,
getAtomVersion: this.getAtomVersion
})

this.portalStatusBarIndicator.attach()
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"temp": "^0.8.3"
},
"dependencies": {
"@atom/teletype-client": "^0.32.0",
"@atom/teletype-client": "^0.33.0",
"etch": "^0.12.6"
},
"consumedServices": {
Expand Down
1 change: 1 addition & 0 deletions test/teletype-package.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,7 @@ suite('TeletypePackage', function () {
commandRegistry: env.commands,
tooltipManager: env.tooltips,
clipboard: new FakeClipboard(),
getAtomVersion: function () { return 'x.y.z' },
tetherDisconnectWindow: 300,
credentialCache
})
Expand Down

0 comments on commit d069864

Please sign in to comment.