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

Commit d069864

Browse files
authored
Merge pull request #317 from atom/improve-diagnostics-for-http-request-errors
Improve diagnostics for package initialization errors
2 parents dfaecf6 + 7cf8d55 commit d069864

File tree

6 files changed

+37
-9
lines changed

6 files changed

+37
-9
lines changed

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ module.exports = new TeletypePackage({
1111
cluster: atom.config.get('teletype.pusherCluster'),
1212
disableStats: true
1313
},
14-
baseURL: atom.config.get('teletype.baseURL')
14+
baseURL: atom.config.get('teletype.baseURL'),
15+
getAtomVersion: atom.getVersion.bind(atom)
1516
})

lib/package-initialization-error-component.js

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const etch = require('etch')
2+
const {URL} = require('url')
23
const $ = etch.dom
34

45
module.exports =
@@ -16,7 +17,6 @@ class PackageInitializationErrorComponent {
1617
render () {
1718
return $.div({className: 'PackageInitializationErrorComponent'},
1819
$.h3(null, 'Teletype initialization failed'),
19-
$.p(null, 'Error: ' + this.props.initializationError.message),
2020
$.p(null, 'Make sure your internet connection is working and restart the package.'),
2121
$.div(null,
2222
$.button(
@@ -31,15 +31,38 @@ class PackageInitializationErrorComponent {
3131
),
3232
$.p(null,
3333
'If the problem persists, visit ',
34-
$.a({href: 'https://github.com/atom/teletype/issues/new', className: 'text-info'}, 'atom/teletype'),
34+
$.a({href: this.getIssueURL(), className: 'text-info'}, 'atom/teletype'),
3535
' and open an issue.'
3636
)
3737
)
3838
}
3939

40+
getIssueURL () {
41+
const {initializationError} = this.props
42+
43+
const url = new URL('https://github.com/atom/teletype/issues/new')
44+
url.searchParams.append('title', 'Package Initialization Error')
45+
url.searchParams.append('body',
46+
'### Diagnostics\n\n' +
47+
'```\n' +
48+
initializationError.diagnosticMessage + '\n\n' +
49+
'```\n' +
50+
'### Versions\n\n' +
51+
`**Teletype version**: v${getTeletypeVersion()}\n` +
52+
`**Atom version**: ${this.props.getAtomVersion()}\n` +
53+
`**Platform**: ${process.platform}\n`
54+
)
55+
56+
return url.href
57+
}
58+
4059
async restartTeletype () {
4160
const {packageManager} = this.props
4261
await packageManager.deactivatePackage('teletype')
4362
await packageManager.activatePackage('teletype')
4463
}
4564
}
65+
66+
function getTeletypeVersion () {
67+
return require('../package.json').version
68+
}

lib/popover-component.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class PopoverComponent {
2323
const {
2424
isClientOutdated, initializationError,
2525
authenticationProvider, portalBindingManager,
26-
commandRegistry, clipboard, workspace, notificationManager, packageManager
26+
commandRegistry, clipboard, workspace, notificationManager, packageManager, getAtomVersion
2727
} = this.props
2828

2929
let activeComponent
@@ -36,6 +36,7 @@ class PopoverComponent {
3636
activeComponent = $(PackageInitializationErrorComponent, {
3737
ref: 'packageInitializationErrorComponent',
3838
packageManager,
39+
getAtomVersion,
3940
initializationError
4041
})
4142
} else if (this.props.authenticationProvider.isSignedIn()) {

lib/teletype-package.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ module.exports =
99
class TeletypePackage {
1010
constructor (options) {
1111
const {
12-
baseURL, clipboard, commandRegistry, credentialCache, notificationManager,
13-
packageManager, pubSubGateway, pusherKey, pusherOptions,
14-
tetherDisconnectWindow, tooltipManager, workspace
12+
baseURL, clipboard, commandRegistry, credentialCache, getAtomVersion,
13+
notificationManager, packageManager, pubSubGateway, pusherKey,
14+
pusherOptions, tetherDisconnectWindow, tooltipManager, workspace
1515
} = options
1616

1717
this.workspace = workspace
@@ -24,6 +24,7 @@ class TeletypePackage {
2424
this.pusherKey = pusherKey
2525
this.pusherOptions = pusherOptions
2626
this.baseURL = baseURL
27+
this.getAtomVersion = getAtomVersion
2728
this.tetherDisconnectWindow = tetherDisconnectWindow
2829
this.credentialCache = credentialCache || new CredentialCache()
2930
this.client = new TeletypeClient({
@@ -132,7 +133,8 @@ class TeletypePackage {
132133
clipboard: this.clipboard,
133134
workspace: this.workspace,
134135
notificationManager: this.notificationManager,
135-
packageManager: this.packageManager
136+
packageManager: this.packageManager,
137+
getAtomVersion: this.getAtomVersion
136138
})
137139

138140
this.portalStatusBarIndicator.attach()

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"temp": "^0.8.3"
2626
},
2727
"dependencies": {
28-
"@atom/teletype-client": "^0.32.0",
28+
"@atom/teletype-client": "^0.33.0",
2929
"etch": "^0.12.6"
3030
},
3131
"consumedServices": {

test/teletype-package.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,6 +1101,7 @@ suite('TeletypePackage', function () {
11011101
commandRegistry: env.commands,
11021102
tooltipManager: env.tooltips,
11031103
clipboard: new FakeClipboard(),
1104+
getAtomVersion: function () { return 'x.y.z' },
11041105
tetherDisconnectWindow: 300,
11051106
credentialCache
11061107
})

0 commit comments

Comments
 (0)