@mablhq/mabl-cli 2.71.0 → 2.72.3

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.
@@ -1132,6 +1132,16 @@ function insertMablScriptsIntoEvent(event, getSnippet) {
1132
1132
  delete event.mablSnippets;
1133
1133
  delete event.mablVariables;
1134
1134
  }
1135
+ function wrapScriptInTryCatch(scriptLines, snippetName) {
1136
+ return [
1137
+ `try {`,
1138
+ ...scriptLines,
1139
+ `} catch (mablSnippetError) {`,
1140
+ ` console.error("Error executing snippet:", mablSnippetError);`,
1141
+ ` pm.expect.fail("Snippet '${snippetName}' execution failed");`,
1142
+ `}`,
1143
+ ];
1144
+ }
1135
1145
  function createPostmanScript(...scripts) {
1136
1146
  return {
1137
1147
  id: (0, exports.uuid)(),
@@ -1154,12 +1164,12 @@ function convertMablSnippetsToExecArray(event, getSnippetFromInvariantId) {
1154
1164
  return '';
1155
1165
  }
1156
1166
  const body = (0, encodingUtil_1.b64DecodeUnicodeNodeOrBrowser)(snippet.body);
1157
- return [
1167
+ return wrapScriptInTryCatch([
1158
1168
  createCommentForApiTestSnippet(snippet, 'start'),
1159
1169
  body,
1160
1170
  createCommentForApiTestSnippet(snippet, 'end'),
1161
1171
  '',
1162
- ].join('\n');
1172
+ ], snippet.name ?? 'Unnamed snippet').join('\n');
1163
1173
  });
1164
1174
  return snippetBodies.flatMap((body) => body.split('\n'));
1165
1175
  }