@@ -5,6 +5,13 @@ import WatchHandler from "./helpers/WatchHandler.js";
55import { getLogger } from "@ui5/logger" ;
66const log = getLogger ( "build:BuildServer" ) ;
77
8+ class AbortBuildError extends Error {
9+ constructor ( message ) {
10+ super ( message ) ;
11+ this . name = "AbortBuildError" ;
12+ }
13+ } ;
14+
815/**
916 * Development server that provides access to built project resources with automatic rebuilding
1017 *
@@ -255,7 +262,7 @@ class BuildServer extends EventEmitter {
255262 #projectResourceChangedLive( project , fileAddedOrRemoved ) {
256263 for ( const { project : affectedProject } of this . #graph. traverseDependents ( project . getName ( ) , true ) ) {
257264 const projectBuildStatus = this . #projectBuildStatus. get ( affectedProject . getName ( ) ) ;
258- projectBuildStatus . abortBuild ( " Source files changed" ) ;
265+ projectBuildStatus . abortBuild ( new AbortBuildError ( ` Source change in project ' ${ project . getName ( ) } '` ) ) ;
259266 if ( fileAddedOrRemoved ) {
260267 // Reset any cached readers in case files were added or removed
261268 projectBuildStatus . resetReaderCache ( ) ;
@@ -353,13 +360,9 @@ class BuildServer extends EventEmitter {
353360 // Project has been built and result can be used
354361 const projectBuildStatus = this . #projectBuildStatus. get ( projectName ) ;
355362 projectBuildStatus . setReader ( project . getReader ( { style : "runtime" } ) ) ;
356- } ) ;
357-
358- try {
359- const builtProjects = await buildPromise ;
360- this . emit ( "buildFinished" , builtProjects ) ;
361- } catch ( err ) {
362- if ( err . name === "AbortError" ) {
363+ } ) . catch ( ( err ) => {
364+ if ( err instanceof AbortBuildError ) {
365+ log . info ( "Build aborted" ) ;
363366 // Build was aborted - do not log as error
364367 // Re-queue any outstanding projects
365368 for ( const projectName of projectsToBuild ) {
@@ -378,10 +381,12 @@ class BuildServer extends EventEmitter {
378381 // Re-throw to be handled by caller
379382 throw err ;
380383 }
381- } finally {
382- // Clear active build
383- this . #activeBuild = null ;
384- }
384+ } ) ;
385+
386+ const builtProjects = await buildPromise ;
387+ this . emit ( "buildFinished" , builtProjects ) ;
388+ // Clear active build
389+ this . #activeBuild = null ;
385390 if ( signal . aborted ) {
386391 log . verbose ( `Build aborted for projects: ${ projectsToBuild . join ( ", " ) } ` ) ;
387392 return ;
@@ -405,7 +410,7 @@ class ProjectBuildStatus {
405410 invalidate ( ) {
406411 this . #state = PROJECT_STATES . INVALIDATED ;
407412 // Ensure any running build is aborted. Then reset the abort controller
408- this . #abortController. abort ( ) ;
413+ this . #abortController. abort ( new AbortBuildError ( "Project invalidated" ) ) ;
409414 this . #abortController = new AbortController ( ) ;
410415 }
411416
0 commit comments