Skip to content

Commit 2bd18d5

Browse files
authored
Refactoring Error Messages for the API (canada-ca#1852)
* affiliation error messages refactored * dmarc summaries error messages refactored * domain error messages refactored * email scan error messages refactored * guidance tag error messages updated * notify error messages updated * organization error messages updated * update summaries error messages * update user error messages * update verified domain error messages * whoops missed the test files * update verified organizations error messages * update web-scan error messages * run prettier on code base * fix up translations after rebase * fix grammar in update user roles error messages * update user role error messages * update translations * more changes to updateUserRole error messages * update translations * fix translation issues from rebase
1 parent 33a1419 commit 2bd18d5

164 files changed

Lines changed: 2295 additions & 1776 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

api-js/src/affiliation/loaders/__tests__/load-affiliation-connections-by-org-id.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ describe('given the load affiliations by org id function', () => {
836836
await affiliationLoader({ orgId: org._id, ...connectionArgs })
837837
} catch (err) {
838838
expect(err).toEqual(
839-
new Error('Unable to query affiliations. Please try again.'),
839+
new Error('Unable to query affiliation(s). Please try again.'),
840840
)
841841
}
842842

@@ -870,7 +870,7 @@ describe('given the load affiliations by org id function', () => {
870870
await affiliationLoader({ orgId: org._id, ...connectionArgs })
871871
} catch (err) {
872872
expect(err).toEqual(
873-
new Error('Unable to load affiliations. Please try again.'),
873+
new Error('Unable to load affiliation(s). Please try again.'),
874874
)
875875
}
876876

api-js/src/affiliation/loaders/__tests__/load-affiliation-connections-by-user-id.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4403,7 +4403,7 @@ describe('given the load affiliations by user id function', () => {
44034403
})
44044404
} catch (err) {
44054405
expect(err).toEqual(
4406-
new Error('Unable to query affiliations. Please try again.'),
4406+
new Error('Unable to query affiliation(s). Please try again.'),
44074407
)
44084408
}
44094409

@@ -4441,7 +4441,7 @@ describe('given the load affiliations by user id function', () => {
44414441
})
44424442
} catch (err) {
44434443
expect(err).toEqual(
4444-
new Error('Unable to load affiliations. Please try again.'),
4444+
new Error('Unable to load affiliation(s). Please try again.'),
44454445
)
44464446
}
44474447

api-js/src/affiliation/loaders/load-affiliation-connections-by-org-id.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,9 @@ export const affiliationConnectionLoaderByOrgId = (
218218
console.error(
219219
`Database error occurred while user: ${userKey} was trying to query affiliations in affiliationConnectionLoaderByOrgId, error: ${err}`,
220220
)
221-
throw new Error(i18n._(t`Unable to query affiliations. Please try again.`))
221+
throw new Error(
222+
i18n._(t`Unable to query affiliation(s). Please try again.`),
223+
)
222224
}
223225

224226
let filteredAffiliations
@@ -228,7 +230,7 @@ export const affiliationConnectionLoaderByOrgId = (
228230
console.error(
229231
`Cursor error occurred while user: ${userKey} was trying to gather affiliations in affiliationConnectionLoaderByOrgId, error: ${err}`,
230232
)
231-
throw new Error(i18n._(t`Unable to load affiliations. Please try again.`))
233+
throw new Error(i18n._(t`Unable to load affiliation(s). Please try again.`))
232234
}
233235

234236
if (filteredAffiliations.affiliations.length === 0) {

api-js/src/affiliation/loaders/load-affiliation-connections-by-user-id.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,9 @@ export const affiliationConnectionLoaderByUserId = (
399399
console.error(
400400
`Database error occurred while user: ${userKey} was trying to query affiliations in affiliationConnectionLoaderByUserId, error: ${err}`,
401401
)
402-
throw new Error(i18n._(t`Unable to query affiliations. Please try again.`))
402+
throw new Error(
403+
i18n._(t`Unable to query affiliation(s). Please try again.`),
404+
)
403405
}
404406

405407
let filteredAffiliations
@@ -409,7 +411,7 @@ export const affiliationConnectionLoaderByUserId = (
409411
console.error(
410412
`Cursor error occurred while user: ${userKey} was trying to gather affiliations in affiliationConnectionLoaderByUserId, error: ${err}`,
411413
)
412-
throw new Error(i18n._(t`Unable to load affiliations. Please try again.`))
414+
throw new Error(i18n._(t`Unable to load affiliation(s). Please try again.`))
413415
}
414416

415417
if (filteredAffiliations.affiliations.length === 0) {

api-js/src/affiliation/mutations/__tests__/invite-user-to-org.test.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,9 +1072,7 @@ describe('invite user to org', () => {
10721072
)
10731073

10741074
const error = [
1075-
new GraphQLError(
1076-
'Unable to invite yourself to an org. Please try again.',
1077-
),
1075+
new GraphQLError('Unable to invite yourself to an org.'),
10781076
]
10791077

10801078
expect(response.errors).toEqual(error)
@@ -1143,7 +1141,7 @@ describe('invite user to org', () => {
11431141
)
11441142

11451143
const error = [
1146-
new GraphQLError('Unable to invite user. Please try again.'),
1144+
new GraphQLError('Unable to invite user to unknown organization.'),
11471145
]
11481146

11491147
expect(response.errors).toEqual(error)
@@ -1237,7 +1235,9 @@ describe('invite user to org', () => {
12371235
)
12381236

12391237
const error = [
1240-
new GraphQLError('Unable to invite user. Please try again.'),
1238+
new GraphQLError(
1239+
'Permission Denied: Please contact organization admin for help with user invitations.',
1240+
),
12411241
]
12421242

12431243
expect(response.errors).toEqual(error)
@@ -1335,7 +1335,9 @@ describe('invite user to org', () => {
13351335
)
13361336

13371337
const error = [
1338-
new GraphQLError('Unable to invite user. Please try again.'),
1338+
new GraphQLError(
1339+
'Permission Denied: Please contact organization admin for help with user invitations.',
1340+
),
13391341
]
13401342

13411343
expect(response.errors).toEqual(error)
@@ -1433,7 +1435,9 @@ describe('invite user to org', () => {
14331435
)
14341436

14351437
const error = [
1436-
new GraphQLError('Unable to invite user. Please try again.'),
1438+
new GraphQLError(
1439+
'Permission Denied: Please contact organization admin for help with user invitations.',
1440+
),
14371441
]
14381442

14391443
expect(response.errors).toEqual(error)
@@ -1551,7 +1555,9 @@ describe('invite user to org', () => {
15511555
)
15521556

15531557
const error = [
1554-
new GraphQLError('Unable to invite user. Please try again.'),
1558+
new GraphQLError(
1559+
'Unable to add user to organization. Please try again.',
1560+
),
15551561
]
15561562

15571563
expect(response.errors).toEqual(error)

api-js/src/affiliation/mutations/__tests__/remove-user-from-org.test.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ describe('removing a user from an organization', () => {
587587

588588
const error = [
589589
new GraphQLError(
590-
'Unable to remove user from organization. Please try again.',
590+
'Unable to remove user from unknown organization.',
591591
),
592592
]
593593

@@ -654,7 +654,7 @@ describe('removing a user from an organization', () => {
654654

655655
const error = [
656656
new GraphQLError(
657-
'Unable to remove user from organization. Please try again.',
657+
'Permission Denied: Please contact organization admin for help with removing users.',
658658
),
659659
]
660660

@@ -721,7 +721,7 @@ describe('removing a user from an organization', () => {
721721

722722
const error = [
723723
new GraphQLError(
724-
'Unable to remove user from organization. Please try again.',
724+
'Unable to remove a user that already does not belong to this organization.',
725725
),
726726
]
727727

@@ -788,7 +788,7 @@ describe('removing a user from an organization', () => {
788788

789789
const error = [
790790
new GraphQLError(
791-
'Unable to remove user from organization. Please try again.',
791+
'Permission Denied: Please contact organization admin for help with removing users.',
792792
),
793793
]
794794

@@ -854,9 +854,7 @@ describe('removing a user from an organization', () => {
854854
)
855855

856856
const error = [
857-
new GraphQLError(
858-
'Unable to remove user from organization. Please try again.',
859-
),
857+
new GraphQLError('Unable to remove user from organization.'),
860858
]
861859

862860
expect(response.errors).toEqual(error)
@@ -923,7 +921,7 @@ describe('removing a user from an organization', () => {
923921

924922
const error = [
925923
new GraphQLError(
926-
'Unable to remove user from organization. Please try again.',
924+
'Unable to remove unknown user from organization.',
927925
),
928926
]
929927

@@ -997,7 +995,7 @@ describe('removing a user from an organization', () => {
997995

998996
const error = [
999997
new GraphQLError(
1000-
'Unable to remove user from organization. Please try again.',
998+
'Unable to remove user from this organization. Please try again.',
1001999
),
10021000
]
10031001

api-js/src/affiliation/mutations/__tests__/update-user-role.test.js

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -581,11 +581,7 @@ describe('update a users role', () => {
581581
},
582582
)
583583

584-
const error = [
585-
new GraphQLError(
586-
'Unable to update your own role. Please try again.',
587-
),
588-
]
584+
const error = [new GraphQLError('Unable to update your own role.')]
589585

590586
expect(response.errors).toEqual(error)
591587
expect(consoleOutput).toEqual([
@@ -636,7 +632,7 @@ describe('update a users role', () => {
636632
)
637633

638634
const error = [
639-
new GraphQLError('Unable to update users role. Please try again.'),
635+
new GraphQLError(`Unable to update role: user unknown.`),
640636
]
641637

642638
expect(response.errors).toEqual(error)
@@ -688,7 +684,7 @@ describe('update a users role', () => {
688684
)
689685

690686
const error = [
691-
new GraphQLError('Unable to update users role. Please try again.'),
687+
new GraphQLError(`Unable to update role: organization unknown.`),
692688
]
693689

694690
expect(response.errors).toEqual(error)
@@ -747,7 +743,9 @@ describe('update a users role', () => {
747743
)
748744

749745
const error = [
750-
new GraphQLError('Unable to update users role. Please try again.'),
746+
new GraphQLError(
747+
'Permission Denied: Please contact organization admin for help with user role changes.',
748+
),
751749
]
752750

753751
expect(response.errors).toEqual(error)
@@ -832,7 +830,9 @@ describe('update a users role', () => {
832830
)
833831

834832
const error = [
835-
new GraphQLError('Unable to update users role. Please try again.'),
833+
new GraphQLError(
834+
'Permission Denied: Please contact organization admin for help with user role changes.',
835+
),
836836
]
837837

838838
expect(response.errors).toEqual(error)
@@ -892,7 +892,7 @@ describe('update a users role', () => {
892892

893893
const error = [
894894
new GraphQLError(
895-
'Unable to update users role. Please invite user to the organization.',
895+
'Unable to update role: user does not belong to organization.',
896896
),
897897
]
898898

@@ -963,7 +963,7 @@ describe('update a users role', () => {
963963

964964
const error = [
965965
new GraphQLError(
966-
'Unable to update users role. Please try again.',
966+
`Permission Denied: Please contact organization admin for help with updating user roles.`,
967967
),
968968
]
969969

@@ -1034,7 +1034,7 @@ describe('update a users role', () => {
10341034

10351035
const error = [
10361036
new GraphQLError(
1037-
'Unable to update users role. Please try again.',
1037+
`Permission Denied: Please contact organization admin for help with updating user roles.`,
10381038
),
10391039
]
10401040

@@ -1106,7 +1106,7 @@ describe('update a users role', () => {
11061106

11071107
const error = [
11081108
new GraphQLError(
1109-
'Unable to update users role. Please try again.',
1109+
`Permission Denied: Please contact organization admin for help with updating user roles.`,
11101110
),
11111111
]
11121112

@@ -1175,7 +1175,7 @@ describe('update a users role', () => {
11751175

11761176
const error = [
11771177
new GraphQLError(
1178-
'Unable to update users role. Please try again.',
1178+
`Permission Denied: Please contact organization admin for help with updating user roles.`,
11791179
),
11801180
]
11811181

@@ -1306,12 +1306,12 @@ describe('update a users role', () => {
13061306
)
13071307

13081308
const error = [
1309-
new GraphQLError('Unable to update users role. Please try again.'),
1309+
new GraphQLError(`Unable to update user's role. Please try again.`),
13101310
]
13111311

13121312
expect(response.errors).toEqual(error)
13131313
expect(consoleOutput).toEqual([
1314-
`Database error occurred when user: ${user._key} attempted to update a users: ${secondaryUser._key} role, error: Error: Database error occurred.`,
1314+
`Database error occurred when user: ${user._key} attempted to update a user's: ${secondaryUser._key} role, error: Error: Database error occurred.`,
13151315
])
13161316
})
13171317
})
@@ -1427,12 +1427,12 @@ describe('update a users role', () => {
14271427
)
14281428

14291429
const error = [
1430-
new GraphQLError('Unable to update users role. Please try again.'),
1430+
new GraphQLError(`Unable to update user's role. Please try again.`),
14311431
]
14321432

14331433
expect(response.errors).toEqual(error)
14341434
expect(consoleOutput).toEqual([
1435-
`Transaction step error occurred when user: ${user._key} attempted to update a users: ${secondaryUser._key} role, error: Error: Transaction error occurred.`,
1435+
`Transaction step error occurred when user: ${user._key} attempted to update a user's: ${secondaryUser._key} role, error: Error: Transaction error occurred.`,
14361436
])
14371437
})
14381438
})
@@ -1492,12 +1492,12 @@ describe('update a users role', () => {
14921492
)
14931493

14941494
const error = [
1495-
new GraphQLError('Unable to update users role. Please try again.'),
1495+
new GraphQLError(`Unable to update user's role. Please try again.`),
14961496
]
14971497

14981498
expect(response.errors).toEqual(error)
14991499
expect(consoleOutput).toEqual([
1500-
`Transaction commit error occurred when user: ${user._key} attempted to update a users: ${secondaryUser._key} role, error: Error: Transaction error occurred.`,
1500+
`Transaction commit error occurred when user: ${user._key} attempted to update a user's: ${secondaryUser._key} role, error: Error: Transaction error occurred.`,
15011501
])
15021502
})
15031503
})
@@ -2691,7 +2691,7 @@ describe('update a users role', () => {
26912691

26922692
expect(response.errors).toEqual(error)
26932693
expect(consoleOutput).toEqual([
2694-
`Database error occurred when user: ${user._key} attempted to update a users: ${secondaryUser._key} role, error: Error: Database error occurred.`,
2694+
`Database error occurred when user: ${user._key} attempted to update a user's: ${secondaryUser._key} role, error: Error: Database error occurred.`,
26952695
])
26962696
})
26972697
})
@@ -2810,7 +2810,7 @@ describe('update a users role', () => {
28102810

28112811
expect(response.errors).toEqual(error)
28122812
expect(consoleOutput).toEqual([
2813-
`Transaction step error occurred when user: ${user._key} attempted to update a users: ${secondaryUser._key} role, error: Error: Transaction error occurred.`,
2813+
`Transaction step error occurred when user: ${user._key} attempted to update a user's: ${secondaryUser._key} role, error: Error: Transaction error occurred.`,
28142814
])
28152815
})
28162816
})
@@ -2873,7 +2873,7 @@ describe('update a users role', () => {
28732873

28742874
expect(response.errors).toEqual(error)
28752875
expect(consoleOutput).toEqual([
2876-
`Transaction commit error occurred when user: ${user._key} attempted to update a users: ${secondaryUser._key} role, error: Error: Transaction error occurred.`,
2876+
`Transaction commit error occurred when user: ${user._key} attempted to update a user's: ${secondaryUser._key} role, error: Error: Transaction error occurred.`,
28772877
])
28782878
})
28792879
})

0 commit comments

Comments
 (0)