mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-21 18:55:19 -04:00
AuthService.randomString: Throw Error instead of returning null
A string with a negative length is invalid, so we should throw here instead of complicating the type with a possible null return value. Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
72b545fec5
commit
53a0c87a53
2 changed files with 7 additions and 1 deletions
|
@ -64,7 +64,7 @@ export class AuthService {
|
|||
|
||||
randomString(length: number): Buffer {
|
||||
if (length <= 0) {
|
||||
return null;
|
||||
throw new Error('randomString cannot have a length < 1');
|
||||
}
|
||||
return randomBytes(length);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue