Skip to content

Commit ded7bb8

Browse files
Update components/sendgrid/actions/create-send/create-send.mjs
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 841f337 commit ded7bb8

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

components/sendgrid/actions/create-send/create-send.mjs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,12 @@ export default {
150150
$.export("$summary", `Successfully created single send ${this.name}`);
151151
return resp;
152152
} catch (e) {
153-
const errors = e.split("Unexpected error (status code: ERR_BAD_REQUEST):")[1];
154-
const errorJson = JSON.parse(errors);
155-
156-
throw new ConfigurationError(errorJson.data.errors[0].message);
153+
} catch (e) {
154+
if (e.response && e.response.data && e.response.data.errors && e.response.data.errors.length > 0) {
155+
throw new ConfigurationError(e.response.data.errors[0].message);
156+
} else {
157+
throw new ConfigurationError("An unexpected error occurred.");
158+
}
157159
}
158160
},
159161
};

0 commit comments

Comments
 (0)