Skip to content

Throw error when SP URL is null #6012

@milanholemans

Description

@milanholemans

While testing a command I used a variable to store my site URL so it didn't clutter my command args too much. However, I was getting a strange error as shown below:

image

This error was due to the fact that I made a typo and --webUrl was null (because the variable I specified didn't exist).

This is because the validator we are using is as follows:

isValidSharePointUrl(url: string): boolean | string {
if (!url) {
return false;
}
if (url.indexOf('https://') !== 0) {
return `${url} is not a valid SharePoint Online site URL`;
}
else {
return true;
}
},

In the command (and other commands) we validate it like this:

const isValidSharePointUrl: boolean | string = validation.isValidSharePointUrl(args.options.webUrl);
if (isValidSharePointUrl !== true) {
return isValidSharePointUrl;
}

Shouldn't we output an error message when the value is null? The current error Error: false doesn't help at all.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions