File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ let nonce = "%%__NONCE__%%";
11
11
let timestamp = "%%__TIMESTAMP__%%" ;
12
12
13
13
async function main ( ) {
14
+ // Initialise wrapper and exit if a failure occurs.
14
15
let init = await wrapper . init ( token ) ;
15
16
if ( init . result === "error" ) {
16
17
console . log ( init . error ) ;
@@ -21,21 +22,19 @@ async function main() {
21
22
let validated = await wrapper . resources . licenses . validate ( resource_id , purchaser_id , fields ) ;
22
23
23
24
if ( validated . result === "error" ) {
24
- console . log ( `Failed to check license due to API Error: ${ validated . error } .` ) ;
25
- console . log ( "Exiting..." ) ;
26
- process . exit ( 0 ) ;
27
- }
25
+ if ( validated . error . code === "ContentNotFoundError" ) {
26
+ console . log ( "No license was found for this user. Exiting..." ) ;
27
+ } else {
28
+ console . log ( `Failed to check license due to API Error: ${ validated . error } .` ) ;
29
+ console . log ( "Exiting..." ) ;
30
+ }
28
31
29
- if ( ! validated . data ) {
30
- console . log ( "No active license was found. Exiting..." ) ;
31
32
process . exit ( 0 ) ;
32
- return ;
33
33
}
34
34
35
35
if ( ! validated . data . active ) {
36
36
console . log ( "A license has been found, but it's been disabled. Exiting..." ) ;
37
37
process . exit ( 0 ) ;
38
- return ;
39
38
}
40
39
41
40
console . log ( "Active license found, returning from function without exiting." ) ;
You can’t perform that action at this time.
0 commit comments