Merge pull request #1707 from thecodingmachine/no_thow_literals
Stopping sending literal errors
This commit is contained in:
commit
4257604229
@ -25,6 +25,7 @@
|
|||||||
],
|
],
|
||||||
"rules": {
|
"rules": {
|
||||||
"no-unused-vars": "off",
|
"no-unused-vars": "off",
|
||||||
"@typescript-eslint/no-explicit-any": "error"
|
"@typescript-eslint/no-explicit-any": "error",
|
||||||
|
"no-throw-literal": "error"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,7 @@ module.exports = {
|
|||||||
"rules": {
|
"rules": {
|
||||||
"no-unused-vars": "off",
|
"no-unused-vars": "off",
|
||||||
"@typescript-eslint/no-explicit-any": "error",
|
"@typescript-eslint/no-explicit-any": "error",
|
||||||
|
"no-throw-literal": "error",
|
||||||
// TODO: remove those ignored rules and write a stronger code!
|
// TODO: remove those ignored rules and write a stronger code!
|
||||||
"@typescript-eslint/no-unsafe-call": "off",
|
"@typescript-eslint/no-unsafe-call": "off",
|
||||||
"@typescript-eslint/restrict-plus-operands": "off",
|
"@typescript-eslint/restrict-plus-operands": "off",
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
const selectedFile = inputAudio.files ? inputAudio.files[0] : null;
|
const selectedFile = inputAudio.files ? inputAudio.files[0] : null;
|
||||||
if (!selectedFile) {
|
if (!selectedFile) {
|
||||||
errorFile = true;
|
errorFile = true;
|
||||||
throw "no file selected";
|
throw new Error("no file selected");
|
||||||
}
|
}
|
||||||
|
|
||||||
const fd = new FormData();
|
const fd = new FormData();
|
||||||
|
@ -76,7 +76,7 @@
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else throw "There is no menu called " + menu;
|
} else throw new Error("There is no menu called " + menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeMenu() {
|
function closeMenu() {
|
||||||
|
@ -106,10 +106,10 @@ class ConnectionManager {
|
|||||||
const code = urlParams.get("code");
|
const code = urlParams.get("code");
|
||||||
const state = urlParams.get("state");
|
const state = urlParams.get("state");
|
||||||
if (!state || !localUserStore.verifyState(state)) {
|
if (!state || !localUserStore.verifyState(state)) {
|
||||||
throw "Could not validate state!";
|
throw new Error("Could not validate state!");
|
||||||
}
|
}
|
||||||
if (!code) {
|
if (!code) {
|
||||||
throw "No Auth code provided";
|
throw new Error("No Auth code provided");
|
||||||
}
|
}
|
||||||
localUserStore.setCode(code);
|
localUserStore.setCode(code);
|
||||||
}
|
}
|
||||||
@ -333,10 +333,10 @@ class ConnectionManager {
|
|||||||
|
|
||||||
if (!token) {
|
if (!token) {
|
||||||
if (!state || !localUserStore.verifyState(state)) {
|
if (!state || !localUserStore.verifyState(state)) {
|
||||||
throw "Could not validate state!";
|
throw new Error("Could not validate state!");
|
||||||
}
|
}
|
||||||
if (!code) {
|
if (!code) {
|
||||||
throw "No Auth code provided";
|
throw new Error("No Auth code provided");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const { authToken, userUuid, textures, email } = await Axios.get(`${PUSHER_URL}/login-callback`, {
|
const { authToken, userUuid, textures, email } = await Axios.get(`${PUSHER_URL}/login-callback`, {
|
||||||
|
@ -691,7 +691,7 @@ export class RoomConnection implements RoomConnection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public getUserId(): number {
|
public getUserId(): number {
|
||||||
if (this.userId === null) throw "UserId cannot be null!";
|
if (this.userId === null) throw new Error("UserId cannot be null!");
|
||||||
return this.userId;
|
return this.userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ export const getRessourceDescriptor = (
|
|||||||
const playerResource = LAYERS[i][textureName];
|
const playerResource = LAYERS[i][textureName];
|
||||||
if (playerResource !== undefined) return playerResource;
|
if (playerResource !== undefined) return playerResource;
|
||||||
}
|
}
|
||||||
throw "Could not find a data for texture " + textureName;
|
throw new Error("Could not find a data for texture " + textureName);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const createLoadingPromise = (
|
export const createLoadingPromise = (
|
||||||
|
@ -66,7 +66,7 @@ export class GameManager {
|
|||||||
|
|
||||||
getCharacterLayers(): string[] {
|
getCharacterLayers(): string[] {
|
||||||
if (!this.characterLayers) {
|
if (!this.characterLayers) {
|
||||||
throw "characterLayers are not set";
|
throw new Error("characterLayers are not set");
|
||||||
}
|
}
|
||||||
return this.characterLayers;
|
return this.characterLayers;
|
||||||
}
|
}
|
||||||
@ -119,7 +119,7 @@ export class GameManager {
|
|||||||
* This will close the socket connections and stop the gameScene, but won't remove it.
|
* This will close the socket connections and stop the gameScene, but won't remove it.
|
||||||
*/
|
*/
|
||||||
leaveGame(targetSceneName: string, sceneClass: Phaser.Scene): void {
|
leaveGame(targetSceneName: string, sceneClass: Phaser.Scene): void {
|
||||||
if (this.currentGameSceneName === null) throw "No current scene id set!";
|
if (this.currentGameSceneName === null) throw new Error("No current scene id set!");
|
||||||
const gameScene: GameScene = this.scenePlugin.get(this.currentGameSceneName) as GameScene;
|
const gameScene: GameScene = this.scenePlugin.get(this.currentGameSceneName) as GameScene;
|
||||||
gameScene.cleanupClosingScene();
|
gameScene.cleanupClosingScene();
|
||||||
gameScene.createSuccessorGameScene(false, false);
|
gameScene.createSuccessorGameScene(false, false);
|
||||||
@ -143,7 +143,7 @@ export class GameManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public getCurrentGameScene(): GameScene {
|
public getCurrentGameScene(): GameScene {
|
||||||
if (this.currentGameSceneName === null) throw "No current scene id set!";
|
if (this.currentGameSceneName === null) throw new Error("No current scene id set!");
|
||||||
return this.scenePlugin.get(this.currentGameSceneName) as GameScene;
|
return this.scenePlugin.get(this.currentGameSceneName) as GameScene;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -453,7 +453,7 @@ export class GameScene extends DirtyScene {
|
|||||||
|
|
||||||
const playerName = gameManager.getPlayerName();
|
const playerName = gameManager.getPlayerName();
|
||||||
if (!playerName) {
|
if (!playerName) {
|
||||||
throw "playerName is not set";
|
throw new Error("playerName is not set");
|
||||||
}
|
}
|
||||||
this.playerName = playerName;
|
this.playerName = playerName;
|
||||||
this.characterLayers = gameManager.getCharacterLayers();
|
this.characterLayers = gameManager.getCharacterLayers();
|
||||||
|
@ -48,7 +48,7 @@ export class CustomizeScene extends AbstractCharacterScene {
|
|||||||
bodyResourceDescription.level < 0 ||
|
bodyResourceDescription.level < 0 ||
|
||||||
bodyResourceDescription.level > 5
|
bodyResourceDescription.level > 5
|
||||||
) {
|
) {
|
||||||
throw "Texture level is null";
|
throw new Error("Texture level is null");
|
||||||
}
|
}
|
||||||
this.layers[bodyResourceDescription.level].unshift(bodyResourceDescription);
|
this.layers[bodyResourceDescription.level].unshift(bodyResourceDescription);
|
||||||
});
|
});
|
||||||
|
@ -26,7 +26,7 @@ export interface ChatMessage {
|
|||||||
function getAuthor(authorId: number): PlayerInterface {
|
function getAuthor(authorId: number): PlayerInterface {
|
||||||
const author = playersStore.getPlayerById(authorId);
|
const author = playersStore.getPlayerById(authorId);
|
||||||
if (!author) {
|
if (!author) {
|
||||||
throw "Could not find data for author " + authorId;
|
throw new Error("Could not find data for author " + authorId);
|
||||||
}
|
}
|
||||||
return author;
|
return author;
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ function hsv_to_rgb(hue: number, saturation: number, brightness: number): { r: n
|
|||||||
b = q;
|
b = q;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw "h_i cannot be " + h_i;
|
throw new Error("h_i cannot be " + h_i);
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
r,
|
r,
|
||||||
|
@ -22,7 +22,7 @@ export function getNavigatorType(): NavigatorType {
|
|||||||
} else if (window.navigator.userAgent.includes("Safari")) {
|
} else if (window.navigator.userAgent.includes("Safari")) {
|
||||||
return NavigatorType.safari;
|
return NavigatorType.safari;
|
||||||
}
|
}
|
||||||
throw "Couldn't detect navigator type";
|
throw new Error("Couldn't detect navigator type");
|
||||||
}
|
}
|
||||||
export function isAndroid(): boolean {
|
export function isAndroid(): boolean {
|
||||||
return window.navigator.userAgent.includes("Android");
|
return window.navigator.userAgent.includes("Android");
|
||||||
|
@ -123,7 +123,7 @@ export class SimplePeer {
|
|||||||
peerConnection.destroy();
|
peerConnection.destroy();
|
||||||
const peerConnexionDeleted = this.PeerConnectionArray.delete(user.userId);
|
const peerConnexionDeleted = this.PeerConnectionArray.delete(user.userId);
|
||||||
if (!peerConnexionDeleted) {
|
if (!peerConnexionDeleted) {
|
||||||
throw "Error to delete peer connection";
|
throw new Error("Error to delete peer connection");
|
||||||
}
|
}
|
||||||
//return this.createPeerConnection(user, localStream);
|
//return this.createPeerConnection(user, localStream);
|
||||||
} else {
|
} else {
|
||||||
@ -177,7 +177,7 @@ export class SimplePeer {
|
|||||||
peerConnection.destroy();
|
peerConnection.destroy();
|
||||||
const peerConnexionDeleted = this.PeerScreenSharingConnectionArray.delete(user.userId);
|
const peerConnexionDeleted = this.PeerScreenSharingConnectionArray.delete(user.userId);
|
||||||
if (!peerConnexionDeleted) {
|
if (!peerConnexionDeleted) {
|
||||||
throw "Error to delete peer connection";
|
throw new Error("Error to delete peer connection");
|
||||||
}
|
}
|
||||||
this.createPeerConnection(user);
|
this.createPeerConnection(user);
|
||||||
} else {
|
} else {
|
||||||
@ -229,7 +229,7 @@ export class SimplePeer {
|
|||||||
|
|
||||||
const userIndex = this.Users.findIndex((user) => user.userId === userId);
|
const userIndex = this.Users.findIndex((user) => user.userId === userId);
|
||||||
if (userIndex < 0) {
|
if (userIndex < 0) {
|
||||||
throw "Couldn't delete user";
|
throw new Error("Couldn't delete user");
|
||||||
} else {
|
} else {
|
||||||
this.Users.splice(userIndex, 1);
|
this.Users.splice(userIndex, 1);
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
],
|
],
|
||||||
"rules": {
|
"rules": {
|
||||||
"no-unused-vars": "off",
|
"no-unused-vars": "off",
|
||||||
"@typescript-eslint/no-explicit-any": "error"
|
"@typescript-eslint/no-explicit-any": "error",
|
||||||
|
"no-throw-literal": "error"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ export class AdminController extends BaseController {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (typeof body.roomId !== "string") {
|
if (typeof body.roomId !== "string") {
|
||||||
throw "Incorrect roomId parameter";
|
throw new Error("Incorrect roomId parameter");
|
||||||
}
|
}
|
||||||
const roomId: string = body.roomId;
|
const roomId: string = body.roomId;
|
||||||
|
|
||||||
@ -86,13 +86,13 @@ export class AdminController extends BaseController {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (typeof body.text !== "string") {
|
if (typeof body.text !== "string") {
|
||||||
throw "Incorrect text parameter";
|
throw new Error("Incorrect text parameter");
|
||||||
}
|
}
|
||||||
if (body.type !== "capacity" && body.type !== "message") {
|
if (body.type !== "capacity" && body.type !== "message") {
|
||||||
throw "Incorrect type parameter";
|
throw new Error("Incorrect type parameter");
|
||||||
}
|
}
|
||||||
if (!body.targets || typeof body.targets !== "object") {
|
if (!body.targets || typeof body.targets !== "object") {
|
||||||
throw "Incorrect targets parameter";
|
throw new Error("Incorrect targets parameter");
|
||||||
}
|
}
|
||||||
const text: string = body.text;
|
const text: string = body.text;
|
||||||
const type: string = body.type;
|
const type: string = body.type;
|
||||||
|
@ -32,7 +32,7 @@ export class AuthenticateController extends BaseController {
|
|||||||
try {
|
try {
|
||||||
const { nonce, state, playUri, redirect } = parse(req.getQuery());
|
const { nonce, state, playUri, redirect } = parse(req.getQuery());
|
||||||
if (!state || !nonce) {
|
if (!state || !nonce) {
|
||||||
throw "missing state and nonce URL parameters";
|
throw new Error("missing state and nonce URL parameters");
|
||||||
}
|
}
|
||||||
|
|
||||||
const loginUri = await openIDClient.authorizationUrl(
|
const loginUri = await openIDClient.authorizationUrl(
|
||||||
|
@ -27,7 +27,7 @@ export class OpenIdProfileController extends BaseController {
|
|||||||
try {
|
try {
|
||||||
const resCheckTokenAuth = await openIDClient.checkTokenAuth(accessToken as string);
|
const resCheckTokenAuth = await openIDClient.checkTokenAuth(accessToken as string);
|
||||||
if (!resCheckTokenAuth.email) {
|
if (!resCheckTokenAuth.email) {
|
||||||
throw "Email was not found";
|
throw new Error("Email was not found");
|
||||||
}
|
}
|
||||||
res.end(
|
res.end(
|
||||||
this.buildHtml(
|
this.buildHtml(
|
||||||
|
@ -671,7 +671,7 @@ export class SocketManager implements ZoneEventListener {
|
|||||||
playGlobalMessageEvent: PlayGlobalMessage
|
playGlobalMessageEvent: PlayGlobalMessage
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
if (!client.tags.includes("admin")) {
|
if (!client.tags.includes("admin")) {
|
||||||
throw "Client is not an admin!";
|
throw new Error("Client is not an admin!");
|
||||||
}
|
}
|
||||||
|
|
||||||
const clientRoomUrl = client.roomId;
|
const clientRoomUrl = client.roomId;
|
||||||
|
Loading…
Reference in New Issue
Block a user