@suffolklitlab/alkiln 4.10.4 → 4.11.1

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/CHANGELOG.md CHANGED
@@ -40,6 +40,15 @@ Format:
40
40
  -->
41
41
  <!-- ## [Unreleased] -->
42
42
 
43
+
44
+ ## [4.11.1] - 2023-03-21
45
+ ### Changed
46
+ - Get error data from server errors
47
+
48
+ ## [4.11.0] - 2023-03-13
49
+ ### Changed
50
+ - Shorten Axios errors to make them more readable (https://github.com/SuffolkLITLab/ALKiln/pull/632)
51
+
43
52
  ## [4.10.4] - 2023-02-15
44
53
  ### Added
45
54
  - Contribution docs
@@ -24,7 +24,11 @@ da.get_dev_id = async function ( timeout ) {
24
24
  timeout: timeout,
25
25
  };
26
26
 
27
- return await axios.request( options );
27
+ try {
28
+ return await axios.request( options );
29
+ } catch (error) {
30
+ throw {...error.toJSON(), data: error.response?.data};
31
+ }
28
32
  }; // Ends da.get_dev_id()
29
33
 
30
34
 
@@ -41,8 +45,11 @@ da.create_project = async function ( project_name, timeout ) {
41
45
  timeout: timeout,
42
46
  };
43
47
 
44
- return await axios.request( options );
45
-
48
+ try {
49
+ return await axios.request( options );
50
+ } catch (error) {
51
+ throw {...error.toJSON(), data: error.response?.data};
52
+ }
46
53
  }; // Ends da.create_project()
47
54
 
48
55
 
@@ -61,7 +68,11 @@ da.pull = async function ( timeout ) {
61
68
  timeout: timeout,
62
69
  };
63
70
 
64
- return await axios.request( options );
71
+ try {
72
+ return await axios.request( options );
73
+ } catch (error) {
74
+ throw {...error.toJSON(), data: error.response?.data};
75
+ }
65
76
  }; // Ends da.pull()
66
77
 
67
78
 
@@ -78,7 +89,11 @@ da.has_task_finished = async function ( task_id, timeout ) {
78
89
  timeout: timeout,
79
90
  };
80
91
 
81
- return await axios.request( options );
92
+ try {
93
+ return await axios.request( options );
94
+ } catch (error) {
95
+ throw {...error.toJSON(), data: error.response?.data};
96
+ }
82
97
  }; // Ends da.has_task_finished()
83
98
 
84
99
 
@@ -95,7 +110,11 @@ da.delete_project = async function ( timeout ) {
95
110
  timeout: timeout,
96
111
  };
97
112
 
98
- return await axios.request( options );
113
+ try {
114
+ return await axios.request( options );
115
+ } catch (error) {
116
+ throw {...error.toJSON(), data: error.response?.data};
117
+ }
99
118
  }; // Ends da.delete_project()
100
119
 
101
120
 
@@ -121,9 +140,9 @@ da.__delete_projects_starting_with = async function ( base_name, starting_num=1,
121
140
  timeout: 30 * 1000,
122
141
  };
123
142
 
124
- await axios.request( options );
143
+ await axios.request( options );
125
144
  } catch ( error ) {
126
- console.log( error )
145
+ console.log( {...error.toJSON(), data: error.response?.data});
127
146
  }
128
147
  name_incrementor++;
129
148
  }
@@ -250,9 +250,7 @@ da_i.loop_to_create_project = async function( creation_options ) {
250
250
  });
251
251
  throw ( error );
252
252
  }
253
-
254
- // ends if error.response
255
- } else {
253
+ } else { // for if error.response
256
254
 
257
255
  // If it's a timeout error, server is busy. Try again after waiting.
258
256
  // Why are we using `max_tries` for timeout error as well?
@@ -435,12 +433,9 @@ da_i.delete_project = async function ( delete_options ) {
435
433
  log.info({ pre: `Trying to delete Project ${ project_name }` });
436
434
 
437
435
  try {
438
-
439
436
  let response = await _da_REST.delete_project( timeout );
440
437
  log.info({ pre: `Deleted Project "${ project_name }"` });
441
-
442
438
  } catch ( error ) {
443
- // Status 400
444
439
  log.error({ pre: `Ran into an error when deleting Project "${ project_name }"` });
445
440
  log.debug({ pre: `See https://docassemble.org/docs/api.html#playground_delete_project.` });
446
441
  throw error;
@@ -20,7 +20,17 @@ const setup = async () => {
20
20
 
21
21
  // Create a project on the da server's account with a unique name then
22
22
  // store it locally for later deleting the project.
23
- let project_name = await da_i.loop_to_create_project();
23
+ let project_name = null;
24
+ // Explicit try-catch prevents "Unhandled promise rejection error"
25
+ // avoids showing confusing node errors to users that they shouldn't have to fix
26
+ try {
27
+ project_name = await da_i.loop_to_create_project();
28
+ } catch (error) {
29
+ log.error({type: `setup`, pre: `an unexpected error occurred while trying to create a docassemble project in the user's account`, data: JSON.stringify(error, null, 4)})
30
+ // we don't re-throw the exception, so make sure to exit with 1 to let Github Actions know the script failed
31
+ process.exitCode = 1;
32
+ return;
33
+ }
24
34
  // Once the name is created, save that name to a local file.
25
35
  session_vars.save_project_name( project_name );
26
36
 
@@ -10,9 +10,17 @@ const takedown = async () => {
10
10
  * Project created for this test.
11
11
  * For local development, clean up project name file. */
12
12
  log.info({ type: `takedown`, pre: `Trying to remove the docassemble Project from the testing account.` });
13
- await da_i.delete_project();
14
- session_vars.delete_project_name();
15
- log.info({ type: `takedown`, pre: `Success! Test takedown has finished successfully.` });
13
+ // Explicit try-catch prevents "Unhandled promise rejection error"
14
+ // avoids showing confusing node errors to users that they shouldn't have to fix
15
+ try {
16
+ await da_i.delete_project();
17
+ session_vars.delete_project_name();
18
+ log.info({ type: `takedown`, pre: `Success! Test takedown has finished successfully.` });
19
+ } catch (error) {
20
+ log.error({type: `takedown`, pre: `could not delete project`, data: JSON.stringify(error, null, 4)})
21
+ // we don't re-throw the exception, so make sure to exit with 1 to let Github Actions know the script failed
22
+ process.exitCode = 1;
23
+ }
16
24
  };
17
25
 
18
26
  takedown();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suffolklitlab/alkiln",
3
- "version": "4.10.4",
3
+ "version": "4.11.1",
4
4
  "description": "Integrated automated end-to-end testing with docassemble, puppeteer, and cucumber.",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {