Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Log unhandled errors during license activation (no-changelog) #6165

Merged
merged 3 commits into from
May 3, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions packages/cli/src/license/license.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,25 +75,29 @@ licenseController.post(
} catch (e) {
const error = e as Error & { errorId?: string };

let message = 'Failed to activate license';

//override specific error messages (to map License Server vocabulary to n8n terms)
switch (error.errorId ?? 'UNSPECIFIED') {
case 'SCHEMA_VALIDATION':
error.message = 'Activation key is in the wrong format';
message = 'Activation key is in the wrong format';
break;
case 'RESERVATION_EXHAUSTED':
error.message =
message =
'Activation key has been used too many times. Please contact [email protected] if you would like to extend it';
break;
case 'RESERVATION_EXPIRED':
error.message = 'Activation key has expired';
message = 'Activation key has expired';
break;
case 'NOT_FOUND':
case 'RESERVATION_CONFLICT':
error.message = 'Activation key not found';
message = 'Activation key not found';
break;
default:
getLogger().error(message, { stack: error.stack ?? 'n/a' });
}

throw new ResponseHelper.BadRequestError(error.message);
throw new ResponseHelper.BadRequestError(message);
}

// Return the read data, plus the management JWT
Expand Down