Skip to content

Commit 8f37883

Browse files
authored
fix: Change error messages to not mention provider (since there might be none) (#1589)
1 parent cb6b998 commit 8f37883

File tree

4 files changed

+6
-8
lines changed

4 files changed

+6
-8
lines changed

packages/use-intl/src/core/createBaseTranslator.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ function getMessagesOrError<Messages extends AbstractIntlMessages>(
113113
if (!messages) {
114114
throw new Error(
115115
process.env.NODE_ENV !== 'production'
116-
? `No messages were configured on the provider.`
116+
? `No messages were configured.`
117117
: undefined
118118
);
119119
}

packages/use-intl/src/core/createFormatter.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export default function createFormatter(props: Props) {
125125
const error = new IntlError(
126126
IntlErrorCode.MISSING_FORMAT,
127127
process.env.NODE_ENV !== 'production'
128-
? `Format \`${formatName}\` is not available. You can configure it on the provider or provide custom options.`
128+
? `Format \`${formatName}\` is not available.`
129129
: undefined
130130
);
131131
onError(error);

packages/use-intl/src/react/useFormatter.test.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ describe('dateTime', () => {
207207

208208
const error: IntlError = onError.mock.calls[0][0];
209209
expect(error.message).toBe(
210-
'MISSING_FORMAT: Format `onlyYear` is not available. You can configure it on the provider or provide custom options.'
210+
'MISSING_FORMAT: Format `onlyYear` is not available.'
211211
);
212212
expect(error.code).toBe(IntlErrorCode.MISSING_FORMAT);
213213
expect(container.textContent).toMatch(/Nov 20 2020/);
@@ -234,7 +234,7 @@ describe('dateTime', () => {
234234

235235
const error: IntlError = onError.mock.calls[0][0];
236236
expect(error.message).toBe(
237-
'MISSING_FORMAT: Format `medium` is not available. You can configure it on the provider or provide custom options.'
237+
'MISSING_FORMAT: Format `medium` is not available.'
238238
);
239239
expect(error.code).toBe(IntlErrorCode.MISSING_FORMAT);
240240
expect(container.textContent).toMatch(/Nov 20 2020/);
@@ -397,7 +397,7 @@ describe('number', () => {
397397

398398
const error: IntlError = onError.mock.calls[0][0];
399399
expect(error.message).toBe(
400-
'MISSING_FORMAT: Format `missing` is not available. You can configure it on the provider or provide custom options.'
400+
'MISSING_FORMAT: Format `missing` is not available.'
401401
);
402402
expect(error.code).toBe(IntlErrorCode.MISSING_FORMAT);
403403
expect(container.textContent).toBe('10000');

packages/use-intl/src/react/useTranslations.test.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -776,9 +776,7 @@ describe('error handling', () => {
776776
expect(onError).toHaveBeenCalledTimes(1);
777777
const error: IntlError = onError.mock.calls[0][0];
778778
expect(error.code).toBe(IntlErrorCode.MISSING_MESSAGE);
779-
expect(error.message).toBe(
780-
'MISSING_MESSAGE: No messages were configured on the provider.'
781-
);
779+
expect(error.message).toBe('MISSING_MESSAGE: No messages were configured.');
782780
screen.getByText('Component.test');
783781
});
784782

0 commit comments

Comments
 (0)