Skip to content

Commit 03e2b36

Browse files
SkyZeroZxthePunderWoman
authored andcommitted
refactor(core): update error message links to versioned docs (#66374)
Error message links now point to the archived documentation site (v*.angular.dev) so that referenced content matches the framework version in use. See #44650 PR Close #66374
1 parent 29f074a commit 03e2b36

19 files changed

+72
-60
lines changed

packages/common/test/directives/ng_for_spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ describe('ngFor', () => {
119119

120120
getComponent().items = <any>'whaaa';
121121
expect(() => fixture.detectChanges()).toThrowError(
122-
`NG02200: Cannot find a differ supporting object 'whaaa' of type 'string'. NgFor only supports binding to Iterables, such as Arrays. Find more at https://angular.dev/errors/NG02200`,
122+
/NG02200: Cannot find a differ supporting object 'whaaa' of type 'string'\. NgFor only supports binding to Iterables, such as Arrays\. Find more at https:\/\/(?:next\.)?angular\.dev\/errors\/NG02200/,
123123
);
124124
}));
125125

@@ -128,7 +128,7 @@ describe('ngFor', () => {
128128

129129
getComponent().items = <any>{'stuff': 'whaaa'};
130130
expect(() => fixture.detectChanges()).toThrowError(
131-
`NG02200: Cannot find a differ supporting object '\[object Object\]' of type 'object'. NgFor only supports binding to Iterables, such as Arrays. Did you mean to use the keyvalue pipe? Find more at https://angular.dev/errors/NG02200`,
131+
/NG02200: Cannot find a differ supporting object '\[object Object\]' of type 'object'\. NgFor only supports binding to Iterables, such as Arrays\. Did you mean to use the keyvalue pipe\? Find more at https:\/\/(?:next\.)?angular\.dev\/errors\/NG02200/,
132132
);
133133
}));
134134

packages/core/src/error_details_base_url.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@
88

99
import {VERSION} from './version';
1010

11+
export const DOC_PAGE_BASE_URL: string = (() => {
12+
const full = VERSION.full;
13+
const isPreRelease =
14+
full.includes('-next') ||
15+
full.includes('-rc') ||
16+
// Avoid direct literal to prevent build stamping replacement
17+
full === '0.0.0' + '-PLACEHOLDER';
18+
const prefix = isPreRelease ? 'next' : `v${VERSION.major}`;
19+
return `https://${prefix}.angular.dev`;
20+
})();
21+
1122
/**
1223
* Base URL for the error details page.
1324
*
@@ -16,10 +27,8 @@ import {VERSION} from './version';
1627
* - packages/core/src/error_details_base_url.ts
1728
*/
1829
export const ERROR_DETAILS_PAGE_BASE_URL: string = (() => {
19-
const versionSubDomain = VERSION.major !== '0' ? `v${VERSION.major}.` : '';
20-
return `https://${versionSubDomain}angular.dev/errors`;
30+
return `${DOC_PAGE_BASE_URL}/errors`;
2131
})();
22-
2332
/**
2433
* URL for the XSS security documentation.
2534
*/

packages/core/src/hydration/api.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import {DEHYDRATED_BLOCK_REGISTRY, DehydratedBlockRegistry} from '../defer/regis
5656
import {gatherDeferBlocksCommentNodes} from './node_lookup_utils';
5757
import {processAndInitTriggers} from '../defer/triggering';
5858
import {DOCUMENT} from '../document';
59+
import {DOC_PAGE_BASE_URL} from '../error_details_base_url';
5960

6061
/**
6162
* Indicates whether the hydration-related code was added,
@@ -148,7 +149,7 @@ function printHydrationStats(injector: Injector) {
148149
(isIncrementalHydrationEnabled(injector)
149150
? `${ngDevMode!.deferBlocksWithIncrementalHydration} defer block(s) were configured to use incremental hydration. `
150151
: '') +
151-
`Learn more at https://angular.dev/guide/hydration.`;
152+
`Learn more at ${DOC_PAGE_BASE_URL}/guide/hydration.`;
152153
// tslint:disable-next-line:no-console
153154
console.log(message);
154155
}

packages/core/src/image_performance_warning.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {inject} from './di/injector_compatibility';
1212
import {formatRuntimeError, RuntimeErrorCode} from './errors';
1313
import {OnDestroy} from './change_detection/lifecycle_hooks';
1414
import {getDocument} from './render3/interfaces/document';
15+
import {ERROR_DETAILS_PAGE_BASE_URL} from './error_details_base_url';
1516

1617
// A delay in milliseconds before the scan is run after onLoad, to avoid any
1718
// potential race conditions with other LCP-related functions. This delay
@@ -213,7 +214,7 @@ function logLazyLCPWarning(src: string) {
213214
`changing the loading value of the LCP image to "eager", or by using the ` +
214215
`NgOptimizedImage directive's prioritization utilities. For more ` +
215216
`information about addressing or disabling this warning, see ` +
216-
`https://angular.dev/errors/NG0913`,
217+
`${ERROR_DETAILS_PAGE_BASE_URL}/NG0913`,
217218
),
218219
);
219220
}
@@ -225,7 +226,7 @@ function logOversizedImageWarning(src: string) {
225226
`An image with src ${src} has intrinsic file dimensions much larger than its ` +
226227
`rendered size. This can negatively impact application loading performance. ` +
227228
`For more information about addressing or disabling this warning, see ` +
228-
`https://angular.dev/errors/NG0913`,
229+
`${ERROR_DETAILS_PAGE_BASE_URL}/NG0913`,
229230
),
230231
);
231232
}

packages/core/test/acceptance/di_forward_ref_spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import {Component, Directive, forwardRef, Host, Inject, ViewChild} from '@angular/core';
1010
import {TestBed} from '../../testing';
11+
import {ERROR_DETAILS_PAGE_BASE_URL} from '../../src/error_details_base_url';
1112

1213
// **NOTE**: More details on why tests relying on `forwardRef` are put into this
1314
// file can be found in the `BUILD.bazel` file declaring the forward ref test target.
@@ -41,7 +42,7 @@ describe('di with forwardRef', () => {
4142
expect(() => TestBed.createComponent(MyComp)).toThrowError(
4243
'NG0200: Circular dependency detected for `DirectiveA`. ' +
4344
'Path: DirectiveA -> DirectiveB -> DirectiveA. ' +
44-
'Find more at https://angular.dev/errors/NG0200',
45+
`Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0200`,
4546
);
4647
});
4748

packages/core/test/acceptance/di_spec.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ import {
6262
DestroyRef,
6363
provideZoneChangeDetection,
6464
} from '../../src/core';
65+
import {ERROR_DETAILS_PAGE_BASE_URL} from '../../src/error_details_base_url';
6566
import {RuntimeError, RuntimeErrorCode} from '../../src/errors';
6667
import {ViewRef as ViewRefInternal} from '../../src/render3/view_ref';
6768
import {TestBed} from '../../testing';
@@ -1263,7 +1264,7 @@ describe('di', () => {
12631264
expect(() => TestBed.createComponent(MyComp)).toThrowError(
12641265
'NG0200: Circular dependency detected for `DirectiveA`. ' +
12651266
'Path: DirectiveA -> DirectiveA. ' +
1266-
'Find more at https://angular.dev/errors/NG0200',
1267+
`Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0200`,
12671268
);
12681269
});
12691270

@@ -2553,7 +2554,7 @@ describe('di', () => {
25532554

25542555
TestBed.configureTestingModule({declarations: [DirectiveString, MyComp, MyApp]});
25552556
expect(() => TestBed.createComponent(MyApp)).toThrowError(
2556-
'NG0201: No provider for String found in NodeInjector. Find more at https://angular.dev/errors/NG0201',
2557+
`NG0201: No provider for String found in NodeInjector. Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0201`,
25572558
);
25582559
});
25592560

@@ -2651,7 +2652,7 @@ describe('di', () => {
26512652

26522653
TestBed.configureTestingModule({declarations: [DirectiveComp, MyComp, MyApp]});
26532654
expect(() => TestBed.createComponent(MyApp)).toThrowError(
2654-
'NG0201: No provider for MyApp found in NodeInjector. Find more at https://angular.dev/errors/NG0201',
2655+
`NG0201: No provider for MyApp found in NodeInjector. Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0201`,
26552656
);
26562657
});
26572658

@@ -6640,7 +6641,7 @@ describe('di', () => {
66406641
'NG0200: Circular dependency detected for `InjectionToken A`. ' +
66416642
'Source: DynamicTestModule. ' +
66426643
'Path: InjectionToken A -> InjectionToken B -> InjectionToken A. ' +
6643-
'Find more at https://angular.dev/errors/NG0200',
6644+
`Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0200`,
66446645
);
66456646
});
66466647

@@ -6676,7 +6677,7 @@ describe('di', () => {
66766677
'NG0200: Circular dependency detected for `InjectionToken A`. ' +
66776678
'Source: DynamicTestModule. ' +
66786679
'Path: InjectionToken A -> InjectionToken B -> InjectionToken A. ' +
6679-
'Find more at https://angular.dev/errors/NG0200',
6680+
`Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0200`,
66806681
);
66816682
});
66826683

@@ -6719,7 +6720,7 @@ describe('di', () => {
67196720
'NG0200: Circular dependency detected for `InjectionToken A`. ' +
67206721
'Source: DynamicTestModule. ' +
67216722
'Path: InjectionToken A -> InjectionToken B -> InjectionToken A. ' +
6722-
'Find more at https://angular.dev/errors/NG0200',
6723+
`Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0200`,
67236724
);
67246725
});
67256726

@@ -6737,7 +6738,7 @@ describe('di', () => {
67376738
expect(() => createInjector(AModule)).toThrowError(
67386739
'NG0200: Circular dependency detected for `AModule`. ' +
67396740
'Path: AModule -> BModule -> AModule. ' +
6740-
'Find more at https://angular.dev/errors/NG0200',
6741+
`Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0200`,
67416742
);
67426743
});
67436744

@@ -6781,7 +6782,7 @@ describe('di', () => {
67816782
'NG0200: Circular dependency detected for `InjectionToken A`. ' +
67826783
'Source: DynamicTestModule. ' +
67836784
'Path: InjectionToken A -> InjectionToken B -> InjectionToken A. ' +
6784-
'Find more at https://angular.dev/errors/NG0200',
6785+
`Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0200`,
67856786
);
67866787
});
67876788

@@ -6818,7 +6819,7 @@ describe('di', () => {
68186819
expect(() => TestBed.createComponent(App)).toThrowError(
68196820
'NG0200: Circular dependency detected for `InjectionToken A`. ' +
68206821
"Path: App -> ('InjectionToken A':AService) -> ('InjectionToken B':BService) -> ('InjectionToken A':AService). " +
6821-
'Find more at https://angular.dev/errors/NG0200',
6822+
`Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0200`,
68226823
);
68236824
});
68246825
});

packages/core/test/application_init_spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
InjectionToken,
1414
provideAppInitializer,
1515
} from '../src/core';
16+
import {ERROR_DETAILS_PAGE_BASE_URL} from '../src/error_details_base_url';
1617
import {EMPTY, Observable, Subscriber} from 'rxjs';
1718

1819
import {TestBed} from '../testing';
@@ -187,7 +188,7 @@ describe('ApplicationInitStatus', () => {
187188
'NG0209: Unexpected type of the `APP_INITIALIZER` token value ' +
188189
`(expected an array, but got string). ` +
189190
'Please check that the `APP_INITIALIZER` token is configured as a ' +
190-
'`multi: true` provider. Find more at https://angular.dev/errors/NG0209',
191+
`\`multi: true\` provider. Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0209`,
191192
);
192193
});
193194
});

packages/core/test/application_ref_spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
ɵDomRendererFactory2 as DomRendererFactory2,
1414
} from '@angular/platform-browser';
1515
import type {ServerModule} from '@angular/platform-server';
16+
import {ERROR_DETAILS_PAGE_BASE_URL} from '../src/error_details_base_url';
1617
import {createTemplate, dispatchEvent, getContent, isNode} from '@angular/private/testing';
1718
import {expect} from '@angular/private/testing/matchers';
1819
import {
@@ -586,7 +587,7 @@ describe('bootstrap', () => {
586587
`NG0403: The module MyModule was bootstrapped, ` +
587588
`but it does not declare "@NgModule.bootstrap" components nor a "ngDoBootstrap" method. ` +
588589
`Please define one of these. ` +
589-
`Find more at https://angular.dev/errors/NG0403`;
590+
`Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0403`;
590591
expect(e.message).toEqual(expectedErrMsg);
591592
expect(mockConsole.res[0].join('#')).toEqual('ERROR#Error: ' + expectedErrMsg);
592593
},

packages/core/test/di/injector_spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,20 @@
77
*/
88

99
import {Injector} from '../../src/core';
10+
import {ERROR_DETAILS_PAGE_BASE_URL} from '../../src/error_details_base_url';
1011

1112
describe('Injector.NULL', () => {
1213
it('should throw if no arg is given', () => {
1314
expect(() => Injector.NULL.get('someToken')).toThrowError(
1415
'NG0201: No provider found for `someToken`. ' +
15-
'Find more at https://angular.dev/errors/NG0201',
16+
`Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0201`,
1617
);
1718
});
1819

1920
it('should throw if THROW_IF_NOT_FOUND is given', () => {
2021
expect(() => Injector.NULL.get('someToken', Injector.THROW_IF_NOT_FOUND)).toThrowError(
2122
'NG0201: No provider found for `someToken`. ' +
22-
'Find more at https://angular.dev/errors/NG0201',
23+
`Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0201`,
2324
);
2425
});
2526

packages/core/test/di/r3_injector_spec.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
ɵɵdefineInjector,
1616
ɵɵinject,
1717
} from '../../src/core';
18+
import {ERROR_DETAILS_PAGE_BASE_URL} from '../../src/error_details_base_url';
1819
import {createInjector} from '../../src/di/create_injector';
1920
import {InternalInjectFlags} from '../../src/di/interface/injector';
2021
import {R3Injector} from '../../src/di/r3_injector';
@@ -339,15 +340,15 @@ describe('InjectorDef-based createInjector()', () => {
339340
expect(() => injector.get(ServiceTwo)).toThrowError(
340341
'NG0201: No provider found for `ServiceTwo`. ' +
341342
'Source: Module. ' +
342-
'Find more at https://angular.dev/errors/NG0201',
343+
`Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0201`,
343344
);
344345
});
345346

346347
it('should throw without the module name when no module', () => {
347348
const injector = createInjector([ServiceTwo]);
348349
expect(() => injector.get(ServiceTwo)).toThrowError(
349350
'NG0201: No provider found for `ServiceTwo`. ' +
350-
'Find more at https://angular.dev/errors/NG0201',
351+
`Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0201`,
351352
);
352353
});
353354

@@ -357,7 +358,7 @@ describe('InjectorDef-based createInjector()', () => {
357358
'NG0201: No provider found for `Service`. ' +
358359
'Source: ModuleWithMissingDep. ' +
359360
'Path: ServiceWithMissingDep -> Service. ' +
360-
'Find more at https://angular.dev/errors/NG0201',
361+
`Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0201`,
361362
);
362363
});
363364

0 commit comments

Comments
 (0)