Skip to content

Commit 55da253

Browse files
refactor: address comments.
1 parent cc37f11 commit 55da253

3 files changed

Lines changed: 17 additions & 8 deletions

File tree

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
# <img src="src/logo.svg" alt="@knighted/develop logo" width="36" height="36" style="vertical-align: middle;" /> <span style="vertical-align: middle;"><code>@knighted/develop</code></span>
1+
<h1>
2+
<img src="src/logo.svg" alt="@knighted/develop logo" width="32" height="32" valign="middle" />
3+
<code>@knighted/develop</code>
4+
</h1>
25

36
CDN-first browser IDE for building UI components with [`@knighted/jsx`](https://github.com/knightedcodemonkey/jsx) and [`@knighted/css`](https://github.com/knightedcodemonkey/css).
47

src/modules/lint-diagnostics.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,8 @@ const normalizeLintDiagnostic = diagnostic => {
4747
}
4848

4949
const formatLintDiagnosticMessage = diagnostic => {
50-
const normalized = normalizeLintDiagnostic(diagnostic)
51-
const ruleSuffix = normalized.ruleId ? ` (${normalized.ruleId})` : ''
52-
return `${normalized.message}${ruleSuffix}`
50+
const ruleSuffix = diagnostic.ruleId ? ` (${diagnostic.ruleId})` : ''
51+
return `${diagnostic.message}${ruleSuffix}`
5352
}
5453

5554
const buildLintDiagnosticsSummary = ({ diagnostics, okHeadline, errorHeadline }) => {

src/modules/type-diagnostics.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,18 @@ export const createTypeDiagnosticsController = ({
292292
{ orderedFallback = false } = {},
293293
) => {
294294
if (orderedFallback) {
295-
const tryUrlAt = async (index, firstError = null) => {
295+
const tryUrlAt = async (index, failures = []) => {
296296
if (index >= urls.length) {
297+
const reasons = failures
298+
.slice(0, 3)
299+
.map(reason => (reason instanceof Error ? reason.message : String(reason)))
300+
const reasonSummary = reasons.length ? ` Causes: ${reasons.join(' | ')}` : ''
301+
297302
throw new Error(
298-
`${errorPrefix}: Tried URLs: ${urls.join(', ')}.${firstError ? ` ${firstError}` : ''}`,
303+
`${errorPrefix}: Tried URLs: ${urls.join(', ')}.${reasonSummary}`,
304+
{
305+
cause: failures.at(-1),
306+
},
299307
)
300308
}
301309

@@ -309,8 +317,7 @@ export const createTypeDiagnosticsController = ({
309317

310318
return response.text()
311319
} catch (error) {
312-
const message = error instanceof Error ? error.message : String(error)
313-
return tryUrlAt(index + 1, firstError ?? message)
320+
return tryUrlAt(index + 1, [...failures, error])
314321
}
315322
}
316323

0 commit comments

Comments
 (0)