Commit 7cff80b
authored
Refactor duplicate error handling into fetchErrorMessage helper (#7644)
## What Changed
Extracts duplicate error handling logic for 404/500 status codes in
`VerifyThenLoadAPIContent` into a reusable `fetchErrorMessage` helper
function.
Addresses review feedback from #7642.
## Type
- [ ] ✨ Feature
- [ ] 🐛 Bug fix
- [x] ♻️ Refactor
- [ ] 🏗️ Build/Infrastructure
- [ ] 🔒 Security
## Testing
No functional change. The helper function encapsulates the same AJAX
call pattern previously duplicated in both 404 and 500 handlers.
Before (repeated in both handlers):
```javascript
404: function () {
try {
$.ajax({
method: "GET",
url: url,
async: false,
dataType: "json",
success: function (data) {
var msg = data && data.message ? data.message : error;
window.CRM.DisplayErrorMessage(url, { message: msg });
},
error: function () {
window.CRM.DisplayErrorMessage(url, { message: error });
},
});
} catch (e) {
window.CRM.DisplayErrorMessage(url, { message: error });
}
}
```
After:
```javascript
404: function () {
fetchErrorMessage(url, error, function (msg) {
window.CRM.DisplayErrorMessage(url, { message: msg });
});
}
```
## Screenshots
N/A - No UI changes
## Security Check
- [ ] Introduces new input validation
- [ ] Modifies authentication/authorization
- [ ] Affects data privacy/GDPR
### Code Quality
- [x] Database: Propel ORM only, no raw SQL
- [x] No deprecated attributes (align, valign, nowrap, border,
cellpadding, cellspacing, bgcolor)
- [x] Bootstrap CSS classes used
- [x] All CSS bundled via webpack
## Pre-Merge
- [x] Tested locally
- [x] No new warnings
- [x] Build passes
- [x] Backward compatible (or migration documented)
<!-- START COPILOT CODING AGENT TIPS -->
---
✨ Let Copilot coding agent [set things up for
you](https://github.com/ChurchCRM/CRM/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot)
— coding agent works faster and does higher quality work when set up for
your repo.1 file changed
+28
-36
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
56 | 78 | | |
57 | 79 | | |
58 | 80 | | |
| |||
62 | 84 | | |
63 | 85 | | |
64 | 86 | | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
83 | 90 | | |
84 | 91 | | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
103 | 95 | | |
104 | 96 | | |
105 | 97 | | |
| |||
0 commit comments