Skip to content

Commit 88f8564

Browse files
author
Manus AI
committed
fix: Handle both array and string error formats in register command
Fixed TypeError when API returns error messages as strings instead of arrays. The error handling now properly handles both formats: - Array: ['error message 1', 'error message 2'] - String: 'error message' This prevents crashes when displaying validation errors from the API.
1 parent d7e9e88 commit 88f8564

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

index.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -807,9 +807,15 @@ async function registerCommand(options) {
807807
if (errorData.errors) {
808808
console.error('\nRegistration failed with the following errors:');
809809
Object.keys(errorData.errors).forEach(field => {
810-
errorData.errors[field].forEach(message => {
811-
console.error(` - ${field}: ${message}`);
812-
});
810+
const fieldErrors = errorData.errors[field];
811+
// Handle both array and string error formats
812+
if (Array.isArray(fieldErrors)) {
813+
fieldErrors.forEach(message => {
814+
console.error(` - ${field}: ${message}`);
815+
});
816+
} else {
817+
console.error(` - ${field}: ${fieldErrors}`);
818+
}
813819
});
814820
} else {
815821
console.error('Registration failed:', errorData.message || 'Unknown error');

0 commit comments

Comments
 (0)