File tree 2 files changed +54
-2
lines changed 2 files changed +54
-2
lines changed Original file line number Diff line number Diff line change @@ -202,8 +202,40 @@ export class ProjectConfigurationsError extends Error {
202
202
> ,
203
203
public readonly partialProjectConfigurationsResult : ConfigurationResult
204
204
) {
205
- super ( 'Failed to create project configurations' ) ;
205
+ const messageFragments = [ 'Failed to create project configurations.' ] ;
206
+ const mergeNodesErrors = [ ] ;
207
+ const unknownErrors = [ ] ;
208
+ for ( const e of errors ) {
209
+ if (
210
+ // Known error type, but unlikely to be caused by the user
211
+ isMergeNodesError ( e )
212
+ ) {
213
+ mergeNodesErrors . push ( e ) ;
214
+ } else if (
215
+ // Known errors that are self-explanatory
216
+ ! isAggregateCreateNodesError ( e ) &&
217
+ ! isProjectsWithNoNameError ( e ) &&
218
+ ! isMultipleProjectsWithSameNameError ( e )
219
+ ) {
220
+ unknownErrors . push ( e ) ;
221
+ }
222
+ }
223
+ if ( mergeNodesErrors . length > 0 ) {
224
+ messageFragments . push (
225
+ `This type of error most likely points to an issue within Nx. Please report it.`
226
+ ) ;
227
+ }
228
+ if ( unknownErrors . length > 0 ) {
229
+ messageFragments . push (
230
+ `If the error cause is not obvious from the below error messages, running "nx reset" may fix it. Please report the issue if you keep seeing it.`
231
+ ) ;
232
+ }
233
+ super ( messageFragments . join ( ' ' ) ) ;
206
234
this . name = this . constructor . name ;
235
+ this . errors = errors ;
236
+ this . stack = errors
237
+ . map ( ( error ) => indentString ( formatErrorStackAndCause ( error ) , 2 ) )
238
+ . join ( '\n' ) ;
207
239
}
208
240
}
209
241
Original file line number Diff line number Diff line change 1
- import { ProjectGraphError } from '../project-graph/error-types' ;
1
+ import type {
2
+ ProjectConfigurationsError ,
3
+ ProjectGraphError ,
4
+ } from '../project-graph/error-types' ;
2
5
import { logger } from './logger' ;
3
6
import { output } from './output' ;
4
7
@@ -33,6 +36,23 @@ export async function handleErrors(
33
36
? formatErrorStackAndCause ( projectGraphError , isVerbose )
34
37
: projectGraphError . getErrors ( ) . map ( ( e ) => e . message ) ,
35
38
} ) ;
39
+ } else if ( err . name === 'ProjectConfigurationsError' ) {
40
+ const projectConfigurationsError = err as ProjectConfigurationsError ;
41
+ let title = projectConfigurationsError . message ;
42
+ if (
43
+ projectConfigurationsError . cause &&
44
+ typeof projectConfigurationsError . cause === 'object' &&
45
+ 'message' in projectConfigurationsError . cause
46
+ ) {
47
+ title += ' ' + projectConfigurationsError . cause . message + '.' ;
48
+ }
49
+
50
+ output . error ( {
51
+ title,
52
+ bodyLines : isVerbose
53
+ ? formatErrorStackAndCause ( projectConfigurationsError , isVerbose )
54
+ : projectConfigurationsError . errors . map ( ( e ) => e . message ) ,
55
+ } ) ;
36
56
} else {
37
57
const lines = ( err . message ? err . message : err . toString ( ) ) . split ( '\n' ) ;
38
58
const bodyLines : string [ ] = lines . slice ( 1 ) ;
You can’t perform that action at this time.
0 commit comments