Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 932d6bf

Browse files
Throw error instead of logging
1 parent 00fb701 commit 932d6bf

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed

‎src/config.ts‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,17 @@ let config: InternalConfig = {
3232

3333
// called when getBy* queries fail. (message, container) => Error
3434
getElementError(message, container) {
35-
const playgroundUrl =
36-
message &&
37-
getConfig().printPlaygroundLink &&
38-
getPlaygroundUrl(container, false)
35+
const playgroundUrl = (() => {
36+
try {
37+
return (
38+
message &&
39+
getConfig().printPlaygroundLink &&
40+
getPlaygroundUrl(container)
41+
)
42+
} catch {
43+
return null
44+
}
45+
})()
3946

4047
const error = new Error(
4148
[

‎src/playground-helper.ts‎

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,13 @@ function encode(value: string) {
1010
return compressToEncodedURIComponent(unindent(value))
1111
}
1212

13-
function getPlaygroundUrl(element: Element | null,logErrors=true) {
13+
function getPlaygroundUrl(element: Element | null) {
1414
if (!element || !('innerHTML' in element)) {
15-
if (logErrors) {
16-
console.log(`The element you're providing isn't a valid DOM element.`)
17-
}
18-
return null
15+
throw new Error(`The element you're providing isn't a valid DOM element.`)
1916
}
2017

2118
if (!element.innerHTML) {
22-
if (logErrors) {
23-
console.log(`The provided element doesn't have any children.`)
24-
}
25-
return null
19+
throw new Error(`The provided element doesn't have any children.`)
2620
}
2721

2822
return `https://testing-playground.com/#markup=${encode(element.innerHTML)}`

‎src/screen.js‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ const debug = (element, maxLength, options) =>
1010
: logDOM(element, maxLength, options)
1111

1212
const logTestingPlaygroundURL = (element = getDocument().body) => {
13-
consturl=getPlaygroundUrl(element)
14-
if(url){
13+
try{
14+
consturl=getPlaygroundUrl(element)
1515
console.log(`Open this URL in your browser\n\n${url}`)
16+
} catch (e) {
17+
console.log(e.message)
1618
}
1719
}
1820

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /