@ontemper/edi 1.1.4 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -11
- package/dist/index.js +4 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -150,18 +150,23 @@ the document, so keep the file and retry (`error.retryable === true`).
|
|
|
150
150
|
```typescript
|
|
151
151
|
import { isEdiInfrastructureError, isTemperEdiClientError } from '@ontemper/edi';
|
|
152
152
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
153
|
+
async function processFile(rawX12: string) {
|
|
154
|
+
try {
|
|
155
|
+
return await edi.fromX12({ input: rawX12 });
|
|
156
|
+
} catch (error) {
|
|
157
|
+
if (isEdiInfrastructureError(error)) {
|
|
158
|
+
// Transient platform fault — the document is fine. Keep the file and rethrow
|
|
159
|
+
// so your poll loop / caller retries.
|
|
160
|
+
throw error;
|
|
161
|
+
}
|
|
162
|
+
if (isTemperEdiClientError(error)) {
|
|
163
|
+
// A verdict on the document (see codes below) — handle it terminally (e.g.
|
|
164
|
+
// quarantine the file) and STOP. Do not rethrow into retry paths.
|
|
165
|
+
console.error('EDI Error:', error.code, error.message);
|
|
166
|
+
return undefined;
|
|
167
|
+
}
|
|
168
|
+
throw error; // unrecognized — surface to the caller
|
|
163
169
|
}
|
|
164
|
-
throw error;
|
|
165
170
|
}
|
|
166
171
|
```
|
|
167
172
|
|
package/dist/index.js
CHANGED
|
@@ -112,9 +112,11 @@ class TemperEdiClient {
|
|
|
112
112
|
if (error instanceof EdiInfrastructureError)
|
|
113
113
|
throw error;
|
|
114
114
|
if ((0, axios_1.isAxiosError)(error)) {
|
|
115
|
-
|
|
115
|
+
// 401 = missing/expired/invalid credential (e.g. the sandbox EDI-gateway JWT),
|
|
116
|
+
// 403 = access denied. Neither is a verdict on the document.
|
|
117
|
+
if (error.status === 401 || error.status === 403)
|
|
116
118
|
throw new TemperEdiClientError({
|
|
117
|
-
message: 'Unauthorized access to EDI service. Reach out to support.',
|
|
119
|
+
message: 'Unauthorized access to EDI service (credentials missing, expired, or invalid). Reach out to support.',
|
|
118
120
|
code: 'edi_unauthorized_error',
|
|
119
121
|
});
|
|
120
122
|
// Transport failures (no response: ECONNREFUSED/timeout/DNS), 5xx, and
|