Skip to content

Commit b961bab

Browse files
committed
nicer error message
1 parent da123c6 commit b961bab

File tree

6 files changed

+13
-24
lines changed

6 files changed

+13
-24
lines changed

dist.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ let version = `${process.env.npm_package_version}-${process.env.TRAVIS_COMMIT}`
88
if (process.env.TRAVIS_TAG) {
99
console.log(`detected TRAVIS_TAG "${process.env.TRAVIS_TAG}", building for release deploy.`)
1010
if (process.env.TRAVIS_TAG !== process.env.npm_package_version) {
11-
throw `travis tag doesn't match npm_package_version: ${process.env.TRAVIS_TAG} vs ${process.env.npm_package_version}`
11+
throw `TRAVIS_TAG contradicts npm_package_version: ${process.env.TRAVIS_TAG} vs ${process.env.npm_package_version}`
1212
}
1313
prod_build_dir = path.resolve(__dirname, 'dist', process.env.npm_package_version)
1414
env.PUBLIC_URL = 'https://cdn.tutorcruncher.com/socket/' + process.env.npm_package_version + '/'
@@ -23,6 +23,7 @@ if (process.env.TRAVIS_TAG) {
2323
env.PUBLIC_URL = 'https://cdn.tutorcruncher.com/socket/dev/'
2424
} else {
2525
console.log('no tag, branch or commit detected, assuming on netlify')
26+
version = process.env.npm_package_version
2627
env.PUBLIC_URL = '/'
2728
}
2829
console.log(`build directory: "${prod_build_dir}"`)

src/components/shared/Error.js

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,16 @@ import React from 'react'
22

33
const Error = ({children}) => (
44
<div className="tcs-errors">
5-
<h2>Error</h2>
65
<p>
76
An error occurred with TutorCruncher socket:
87
</p>
98
<p className="tcs-error-content">{children}</p>
10-
<dl>
11-
<dt>If you're visiting this site:</dt>
12-
<dd>
13-
Get in touch with the owners of the site and let them know their TutorCruncher socket plugin isn't working.
14-
</dd>
15-
16-
<dt>If you're developing this site:</dt>
17-
<dd>
18-
You might get more information from the developer console, if you can't work out what's wrong contact
19-
20-
</dd>
21-
</dl>
9+
<p>
10+
It's likely that you've configured socket wrongly. You might get more information from the developer console, or
11+
<a target="_blank" rel="noopener noreferrer" href="https://help.tutorcruncher.com/tc-socket/">help.tutorcruncher.com/tc-socket/</a>,
12+
if you can't work out what's wrong contact [email protected].
13+
</p>
2214
</div>
2315
)
2416

2517
export default Error
26-

src/styles/tools.scss

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@
3939
}
4040

4141
.tcs-errors {
42-
background-color: $brand-colour;
43-
color: white;
4442
margin: 5px;
4543
padding: 10px 10px;
4644
font-size: 13px;
@@ -49,7 +47,7 @@
4947
}
5048
.tcs-error-content {
5149
font-family: monospace;
52-
background-color: darken($brand-colour, 5%);
50+
background-color: darken(white, 5%);
5351
padding: 20px 10px;
5452
white-space: pre-wrap;
5553
word-wrap: break-word;

src/tests/index.test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ it('converts contractor filter', () => {
2222
div.setAttribute('id', 'socket')
2323
document.body.appendChild(div)
2424
const r = window.socket('good', {
25-
// router_mode: 'history',
25+
router_mode: 'history',
2626
mode: 'grid',
2727
labels_include: ['foobar'],
2828
labels_exclude: ['spam'],
@@ -33,5 +33,4 @@ it('converts contractor filter', () => {
3333
'label': ['foobar'],
3434
'label_exclude': ['spam'],
3535
})
36-
// console.log(pretty_html(div.innerHTML))
3736
})

src/tests/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const RESPONSES = {
3939
})
4040
}
4141

42-
export function MockXMLHttpRequest () {
42+
function MockXMLHttpRequest () {
4343
let _method, _url
4444
const _headers = {}
4545
this.open = function (method, url) {

src/utils.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ function request (app, path, send_data, method, expected_statuses) {
9898
const xhr = new XMLHttpRequest()
9999
const on_error = msg => {
100100
console.error('request error', msg, url, xhr)
101-
reject(msg)
102101
app.setState({error: msg})
102+
reject(msg)
103103
}
104104
xhr.open(method, url)
105105
xhr.setRequestHeader('Accept', 'application/json')
@@ -116,10 +116,10 @@ function request (app, path, send_data, method, expected_statuses) {
116116
})
117117
}
118118
} else {
119-
on_error(`wrong response code ${xhr.status}`)
119+
on_error(`wrong response code ${xhr.status}, Response: ${xhr.responseText.substr(0, 500)}`)
120120
}
121121
}
122-
xhr.onerror = () => on_error(`${xhr.statusText}: ${xhr.status}`)
122+
xhr.onerror = () => on_error(`Error requesting data ${xhr.statusText}: ${xhr.status}`)
123123
xhr.send(send_data)
124124
})
125125
}

0 commit comments

Comments
 (0)