Skip to content

Commit 6bd88de

Browse files
Merge pull request #104 from mailtrap/fix-axios-error-parsing
Fix axios error parsing
2 parents c66d455 + d54fe04 commit 6bd88de

File tree

4 files changed

+853
-48
lines changed

4 files changed

+853
-48
lines changed

src/__tests__/lib/api/resources/ContactExports.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ describe("lib/api/resources/ContactExports: ", () => {
111111
} catch (error) {
112112
expect(error).toBeInstanceOf(MailtrapError);
113113
if (error instanceof MailtrapError) {
114-
// axios logger returns "[object Object]" for error objects, so we check for that
115-
expect(error.message).toBe("[object Object]");
114+
// When errors object doesn't match recognized pattern, falls back to default Axios error message
115+
expect(error.message).toBe("Request failed with status code 422");
116116
}
117117
}
118118
});

src/__tests__/lib/api/resources/ContactImports.test.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,9 @@ describe("lib/api/resources/ContactImports: ", () => {
198198
} catch (error) {
199199
expect(error).toBeInstanceOf(MailtrapError);
200200
if (error instanceof MailtrapError) {
201-
// Note: Current axios-logger doesn't properly handle array of objects format,
202-
// so it falls back to stringifying the array, resulting in [object Object],[object Object]
203-
// This test documents the current behavior. Updating axios-logger to properly
204-
// parse this format will be a separate task.
205-
expect(error.message).toBe("[object Object],[object Object]");
201+
expect(error.message).toBe(
202+
"invalid-email-1: email: is invalid, is required | invalid-email-2: Contact limit exceeded"
203+
);
206204
}
207205
}
208206
});

0 commit comments

Comments
 (0)