11import { getProxyStorefrontHeaders , patchRenderingResponse } from './proxy.js'
22import { getInMemoryTemplates , injectHotReloadScript } from './hot-reload/server.js'
33import { render } from './storefront-renderer.js'
4+ import { getErrorPage } from './hot-reload/error-page.js'
45import { getExtensionInMemoryTemplates } from '../theme-ext-environment/theme-ext-server.js'
56import { logRequestLine } from '../log-request-line.js'
67import { defineEventHandler , getCookie , setResponseHeader , setResponseStatus , type H3Error } from 'h3'
@@ -31,6 +32,17 @@ export function getHtmlHandler(theme: Theme, ctx: DevServerContext) {
3132
3233 assertThemeId ( response , html , String ( theme . id ) )
3334
35+ if ( ctx . localThemeFileSystem . uploadErrors . size > 0 ) {
36+ html = getErrorPage ( {
37+ title : 'Failed to Upload Theme Files' ,
38+ header : 'Upload Errors' ,
39+ errors : Array . from ( ctx . localThemeFileSystem . uploadErrors . entries ( ) ) . map ( ( [ file , errors ] ) => ( {
40+ message : file ,
41+ code : errors . join ( '\n' ) ,
42+ } ) ) ,
43+ } )
44+ }
45+
3446 if ( ctx . options . liveReload !== 'off' ) {
3547 html = injectHotReloadScript ( html )
3648 }
@@ -52,8 +64,12 @@ export function getHtmlHandler(theme: Theme, ctx: DevServerContext) {
5264 let errorPageHtml = getErrorPage ( {
5365 title,
5466 header : title ,
55- message : [ ...rest , cause ?. message ?? error . message ] . join ( '<br>' ) ,
56- code : error . stack ?. replace ( `${ error . message } \n` , '' ) ?? '' ,
67+ errors : [
68+ {
69+ message : [ ...rest , cause ?. message ?? error . message ] . join ( '<br>' ) ,
70+ code : error . stack ?. replace ( `${ error . message } \n` , '' ) ?? '' ,
71+ } ,
72+ ] ,
5773 } )
5874
5975 if ( ctx . options . liveReload !== 'off' ) {
@@ -65,24 +81,6 @@ export function getHtmlHandler(theme: Theme, ctx: DevServerContext) {
6581 } )
6682}
6783
68- function getErrorPage ( options : { title : string ; header : string ; message : string ; code : string } ) {
69- const html = String . raw
70-
71- return html `< html >
72- < head >
73- < title > ${ options . title ?? 'Unknown error' } </ title >
74- </ head >
75- < body
76- id ="full-error-page "
77- style ="display: flex; flex-direction: column; align-items: center; padding-top: 20px; font-family: Arial "
78- >
79- < h2 > ${ options . header } </ h2 >
80- < p > ${ options . message } </ p >
81- < pre > ${ options . code } </ pre >
82- </ body >
83- </ html > `
84- }
85-
8684function assertThemeId ( response : Response , html : string , expectedThemeId : string ) {
8785 /**
8886 * DOM example:
0 commit comments