@mailiy/sdk 0.2.0 → 0.3.0
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/dist/mailiy.d.ts +3 -1
- package/dist/mailiy.js +8 -3
- package/package.json +1 -1
package/dist/mailiy.d.ts
CHANGED
|
@@ -237,7 +237,9 @@ export declare class MailiyError extends Error {
|
|
|
237
237
|
name: string;
|
|
238
238
|
readonly code: string;
|
|
239
239
|
readonly status: number;
|
|
240
|
-
|
|
240
|
+
/** With missing_fields: the required fields that were missing or empty. */
|
|
241
|
+
readonly fields: string[] | undefined;
|
|
242
|
+
constructor(code: string, status: number, fields?: string[]);
|
|
241
243
|
}
|
|
242
244
|
export declare const DEFAULT_BASE_URL = "https://mailiy.com";
|
|
243
245
|
export declare const createMailiy: (options?: MailiyOptions) => {
|
package/dist/mailiy.js
CHANGED
|
@@ -10,10 +10,15 @@ export class MailiyError extends Error {
|
|
|
10
10
|
name = "MailiyError";
|
|
11
11
|
code;
|
|
12
12
|
status;
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
/** With missing_fields: the required fields that were missing or empty. */
|
|
14
|
+
fields;
|
|
15
|
+
constructor(code, status, fields) {
|
|
16
|
+
super(fields
|
|
17
|
+
? `Mailiy API error ${status}: ${code} (${fields.join(", ")})`
|
|
18
|
+
: `Mailiy API error ${status}: ${code}`);
|
|
15
19
|
this.code = code;
|
|
16
20
|
this.status = status;
|
|
21
|
+
this.fields = fields;
|
|
17
22
|
}
|
|
18
23
|
}
|
|
19
24
|
const form = (id) => `/forms/${encodeURIComponent(id)}`;
|
|
@@ -41,7 +46,7 @@ export const createMailiy = (options = {}) => {
|
|
|
41
46
|
});
|
|
42
47
|
const json = (await res.json().catch(() => ({})));
|
|
43
48
|
if (!res.ok) {
|
|
44
|
-
throw new MailiyError(json.error ?? json.code ?? res.statusText, res.status);
|
|
49
|
+
throw new MailiyError(json.error ?? json.code ?? res.statusText, res.status, json.fields);
|
|
45
50
|
}
|
|
46
51
|
return { headers: res.headers, json };
|
|
47
52
|
};
|