Commit 07b39724 authored by nanahira's avatar nanahira

adapt SessionError changes

parent 6e65943a
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
"peerDependencies": { "peerDependencies": {
"@nestjs/common": "^9.0.3 || ^8.0.0", "@nestjs/common": "^9.0.3 || ^8.0.0",
"@nestjs/core": "^9.0.3 || ^8.0.0", "@nestjs/core": "^9.0.3 || ^8.0.0",
"koishi": "^4.9.7", "koishi": "^4.10.1",
"rxjs": "^7.5.5" "rxjs": "^7.5.5"
} }
}, },
...@@ -1243,22 +1243,22 @@ ...@@ -1243,22 +1243,22 @@
} }
}, },
"node_modules/@koishijs/core": { "node_modules/@koishijs/core": {
"version": "4.9.7", "version": "4.10.1",
"resolved": "https://registry.npmjs.org/@koishijs/core/-/core-4.9.7.tgz", "resolved": "https://registry.npmjs.org/@koishijs/core/-/core-4.10.1.tgz",
"integrity": "sha512-jmt6BKvH0az25z/BJs4SNFn9dvx7Ji3TjIRl5AtvagO0bzOQfbn1Tavhtfn3sHVJqQUQIZQcFR3969G4dvchhA==", "integrity": "sha512-+1Is4rGASRllDz6SzQmkzWjjS0MgWhkqQfmDXuaV/h3H9zGrP0HAlZ7y4Jyj5O/QmNL4JVpQM3ENoLS/lZ32eA==",
"peer": true, "peer": true,
"dependencies": { "dependencies": {
"@koishijs/utils": "^6.2.4", "@koishijs/utils": "^6.2.5",
"@minatojs/core": "^1.3.2", "@minatojs/core": "^1.3.2",
"@satorijs/core": "^1.3.1", "@satorijs/core": "^1.3.7",
"cordis": "^2.5.0", "cordis": "^2.5.0",
"cosmokit": "^1.3.3" "cosmokit": "^1.3.3"
} }
}, },
"node_modules/@koishijs/utils": { "node_modules/@koishijs/utils": {
"version": "6.2.4", "version": "6.2.5",
"resolved": "https://registry.npmjs.org/@koishijs/utils/-/utils-6.2.4.tgz", "resolved": "https://registry.npmjs.org/@koishijs/utils/-/utils-6.2.5.tgz",
"integrity": "sha512-AfZA1TX8oOQCNFTOmG5cBRPC0YbSUPgbUYkninFg8F2sp98C8VSn1hua1OVjCM5zC9XISWtj5QpKJHPJRIa+BA==", "integrity": "sha512-ZpiHO6LBRIUm/bWJlGHC2N/f6hl0jgVU2QmUwiL3PfAH4i2xu17TZpU8hoQkrP751Lw37W9GcXoxw22mGaqdXw==",
"peer": true, "peer": true,
"dependencies": { "dependencies": {
"cosmokit": "^1.3.3", "cosmokit": "^1.3.3",
...@@ -1543,14 +1543,14 @@ ...@@ -1543,14 +1543,14 @@
} }
}, },
"node_modules/@satorijs/core": { "node_modules/@satorijs/core": {
"version": "1.3.1", "version": "1.3.7",
"resolved": "https://registry.npmjs.org/@satorijs/core/-/core-1.3.1.tgz", "resolved": "https://registry.npmjs.org/@satorijs/core/-/core-1.3.7.tgz",
"integrity": "sha512-kwjHQ+PYtY97/RBN2D0B5q4Duf6t5xwbHa8qQFVMQ2K1w+Rq0gbwke4eccsj6l5w0gjo5W5UIJUcnwrDYo4sww==", "integrity": "sha512-9orP2YYokEwBapEMZ6obPzKSOVpcS0TOnUVnJM12YM+22HgxDdXd3cNxTksogiPeEvBvvuR5iuwpkOSFlLdaIA==",
"peer": true, "peer": true,
"dependencies": { "dependencies": {
"@satorijs/element": "^2.0.0", "@satorijs/element": "^2.0.0",
"cordis": "^2.5.0", "cordis": "^2.5.0",
"cordis-axios": "^2.1.3", "cordis-axios": "^2.1.4",
"cosmokit": "^1.3.3", "cosmokit": "^1.3.3",
"reggol": "^1.3.1", "reggol": "^1.3.1",
"schemastery": "^3.5.4", "schemastery": "^3.5.4",
...@@ -1567,13 +1567,13 @@ ...@@ -1567,13 +1567,13 @@
} }
}, },
"node_modules/@satorijs/satori": { "node_modules/@satorijs/satori": {
"version": "1.3.1", "version": "1.3.7",
"resolved": "https://registry.npmjs.org/@satorijs/satori/-/satori-1.3.1.tgz", "resolved": "https://registry.npmjs.org/@satorijs/satori/-/satori-1.3.7.tgz",
"integrity": "sha512-T7elZqVtoQiXo6rLxlNx8KB0Y3b8zJuuSTjiSNjrqhEvd0QCGKxSzs3RSvCfIHqc5kdhXzdH48CEE5hQgYkrFw==", "integrity": "sha512-97POcpucME22ALdM8TqosGvNJWu6cNere0fE4NcHVhh0LXhuWyhMN5kviqNqeyZisDSK2EGd4ZqKUVxlQkxqDQ==",
"peer": true, "peer": true,
"dependencies": { "dependencies": {
"@koa/router": "^10.1.1", "@koa/router": "^10.1.1",
"@satorijs/core": "1.3.1", "@satorijs/core": "1.3.7",
"@types/koa": "*", "@types/koa": "*",
"@types/koa__router": "*", "@types/koa__router": "*",
"@types/ws": "^8.5.3", "@types/ws": "^8.5.3",
...@@ -1592,29 +1592,6 @@ ...@@ -1592,29 +1592,6 @@
"node": ">=12.0.0" "node": ">=12.0.0"
} }
}, },
"node_modules/@satorijs/satori/node_modules/@tootallnate/once": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-2.0.0.tgz",
"integrity": "sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A==",
"peer": true,
"engines": {
"node": ">= 10"
}
},
"node_modules/@satorijs/satori/node_modules/http-proxy-agent": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-5.0.0.tgz",
"integrity": "sha512-n2hY8YdoRE1i7r6M0w9DIw5GgZN0G25P8zLCRQ8rjXtTU3vsNFBI/vWK/UIeE6g5MUUz6avwAPXmL6Fy9D/90w==",
"peer": true,
"dependencies": {
"@tootallnate/once": "2",
"agent-base": "6",
"debug": "4"
},
"engines": {
"node": ">= 6"
}
},
"node_modules/@satorijs/satori/node_modules/path-to-regexp": { "node_modules/@satorijs/satori/node_modules/path-to-regexp": {
"version": "6.2.1", "version": "6.2.1",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.2.1.tgz", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.2.1.tgz",
...@@ -1651,6 +1628,15 @@ ...@@ -1651,6 +1628,15 @@
"integrity": "sha512-OvjF+z51L3ov0OyAU0duzsYuvO01PH7x4t6DJx+guahgTnBHkhJdG7soQeTSFLWN3efnHyibZ4Z8l2EuWwJN3A==", "integrity": "sha512-OvjF+z51L3ov0OyAU0duzsYuvO01PH7x4t6DJx+guahgTnBHkhJdG7soQeTSFLWN3efnHyibZ4Z8l2EuWwJN3A==",
"peer": true "peer": true
}, },
"node_modules/@tootallnate/once": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-2.0.0.tgz",
"integrity": "sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A==",
"peer": true,
"engines": {
"node": ">= 10"
}
},
"node_modules/@types/accepts": { "node_modules/@types/accepts": {
"version": "1.3.5", "version": "1.3.5",
"resolved": "https://registry.npmjs.org/@types/accepts/-/accepts-1.3.5.tgz", "resolved": "https://registry.npmjs.org/@types/accepts/-/accepts-1.3.5.tgz",
...@@ -2888,9 +2874,9 @@ ...@@ -2888,9 +2874,9 @@
} }
}, },
"node_modules/cordis-axios": { "node_modules/cordis-axios": {
"version": "2.1.3", "version": "2.1.4",
"resolved": "https://registry.npmjs.org/cordis-axios/-/cordis-axios-2.1.3.tgz", "resolved": "https://registry.npmjs.org/cordis-axios/-/cordis-axios-2.1.4.tgz",
"integrity": "sha512-W6RCzZ4u+q/2D+BSAYV3aA3dMuz1bi+c9L1RI8g9SLaA5Z2QoaJ5zX1faIrS8y79AWtXm8joIGj+gzPVnvO8ww==", "integrity": "sha512-znwVVXxmvv3/RHY/5i9sDjmEGOrR0dki+QcfwawnrVlM5R8YqHwFLlZTapzbuP8pKvHjJ9GfkkQYwk5CaTFWQg==",
"peer": true, "peer": true,
"dependencies": { "dependencies": {
"axios": "^1.1.2", "axios": "^1.1.2",
...@@ -4174,6 +4160,20 @@ ...@@ -4174,6 +4160,20 @@
"node": ">= 0.8" "node": ">= 0.8"
} }
}, },
"node_modules/http-proxy-agent": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-5.0.0.tgz",
"integrity": "sha512-n2hY8YdoRE1i7r6M0w9DIw5GgZN0G25P8zLCRQ8rjXtTU3vsNFBI/vWK/UIeE6g5MUUz6avwAPXmL6Fy9D/90w==",
"peer": true,
"dependencies": {
"@tootallnate/once": "2",
"agent-base": "6",
"debug": "4"
},
"engines": {
"node": ">= 6"
}
},
"node_modules/https-proxy-agent": { "node_modules/https-proxy-agent": {
"version": "5.0.1", "version": "5.0.1",
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz",
...@@ -5256,14 +5256,14 @@ ...@@ -5256,14 +5256,14 @@
} }
}, },
"node_modules/koishi": { "node_modules/koishi": {
"version": "4.9.7", "version": "4.10.1",
"resolved": "https://registry.npmjs.org/koishi/-/koishi-4.9.7.tgz", "resolved": "https://registry.npmjs.org/koishi/-/koishi-4.10.1.tgz",
"integrity": "sha512-InvvfPx5sqRkgOlTWksQu1dWjASCcf92guRGQmm+UIqZh0GBTJi+uFmpAMPA/E+nHOoLDOy/U9DVtpSPipi2+g==", "integrity": "sha512-nET+NfATO+99tNKasgPpyZzFv3kmjzrDmSyJmPlWDsokbjvouMIQHh6EGBiwLCipp7KKsQNZabB3FEFbwzL7Qg==",
"peer": true, "peer": true,
"dependencies": { "dependencies": {
"@koishijs/core": "^4.9.7", "@koishijs/core": "^4.10.1",
"@koishijs/utils": "^6.2.4", "@koishijs/utils": "^6.2.5",
"@satorijs/satori": "^1.3.1", "@satorijs/satori": "^1.3.7",
"file-type": "^16.5.4", "file-type": "^16.5.4",
"ns-require": "^1.1.4" "ns-require": "^1.1.4"
}, },
...@@ -8500,22 +8500,22 @@ ...@@ -8500,22 +8500,22 @@
} }
}, },
"@koishijs/core": { "@koishijs/core": {
"version": "4.9.7", "version": "4.10.1",
"resolved": "https://registry.npmjs.org/@koishijs/core/-/core-4.9.7.tgz", "resolved": "https://registry.npmjs.org/@koishijs/core/-/core-4.10.1.tgz",
"integrity": "sha512-jmt6BKvH0az25z/BJs4SNFn9dvx7Ji3TjIRl5AtvagO0bzOQfbn1Tavhtfn3sHVJqQUQIZQcFR3969G4dvchhA==", "integrity": "sha512-+1Is4rGASRllDz6SzQmkzWjjS0MgWhkqQfmDXuaV/h3H9zGrP0HAlZ7y4Jyj5O/QmNL4JVpQM3ENoLS/lZ32eA==",
"peer": true, "peer": true,
"requires": { "requires": {
"@koishijs/utils": "^6.2.4", "@koishijs/utils": "^6.2.5",
"@minatojs/core": "^1.3.2", "@minatojs/core": "^1.3.2",
"@satorijs/core": "^1.3.1", "@satorijs/core": "^1.3.7",
"cordis": "^2.5.0", "cordis": "^2.5.0",
"cosmokit": "^1.3.3" "cosmokit": "^1.3.3"
} }
}, },
"@koishijs/utils": { "@koishijs/utils": {
"version": "6.2.4", "version": "6.2.5",
"resolved": "https://registry.npmjs.org/@koishijs/utils/-/utils-6.2.4.tgz", "resolved": "https://registry.npmjs.org/@koishijs/utils/-/utils-6.2.5.tgz",
"integrity": "sha512-AfZA1TX8oOQCNFTOmG5cBRPC0YbSUPgbUYkninFg8F2sp98C8VSn1hua1OVjCM5zC9XISWtj5QpKJHPJRIa+BA==", "integrity": "sha512-ZpiHO6LBRIUm/bWJlGHC2N/f6hl0jgVU2QmUwiL3PfAH4i2xu17TZpU8hoQkrP751Lw37W9GcXoxw22mGaqdXw==",
"peer": true, "peer": true,
"requires": { "requires": {
"cosmokit": "^1.3.3", "cosmokit": "^1.3.3",
...@@ -8661,14 +8661,14 @@ ...@@ -8661,14 +8661,14 @@
} }
}, },
"@satorijs/core": { "@satorijs/core": {
"version": "1.3.1", "version": "1.3.7",
"resolved": "https://registry.npmjs.org/@satorijs/core/-/core-1.3.1.tgz", "resolved": "https://registry.npmjs.org/@satorijs/core/-/core-1.3.7.tgz",
"integrity": "sha512-kwjHQ+PYtY97/RBN2D0B5q4Duf6t5xwbHa8qQFVMQ2K1w+Rq0gbwke4eccsj6l5w0gjo5W5UIJUcnwrDYo4sww==", "integrity": "sha512-9orP2YYokEwBapEMZ6obPzKSOVpcS0TOnUVnJM12YM+22HgxDdXd3cNxTksogiPeEvBvvuR5iuwpkOSFlLdaIA==",
"peer": true, "peer": true,
"requires": { "requires": {
"@satorijs/element": "^2.0.0", "@satorijs/element": "^2.0.0",
"cordis": "^2.5.0", "cordis": "^2.5.0",
"cordis-axios": "^2.1.3", "cordis-axios": "^2.1.4",
"cosmokit": "^1.3.3", "cosmokit": "^1.3.3",
"reggol": "^1.3.1", "reggol": "^1.3.1",
"schemastery": "^3.5.4", "schemastery": "^3.5.4",
...@@ -8685,13 +8685,13 @@ ...@@ -8685,13 +8685,13 @@
} }
}, },
"@satorijs/satori": { "@satorijs/satori": {
"version": "1.3.1", "version": "1.3.7",
"resolved": "https://registry.npmjs.org/@satorijs/satori/-/satori-1.3.1.tgz", "resolved": "https://registry.npmjs.org/@satorijs/satori/-/satori-1.3.7.tgz",
"integrity": "sha512-T7elZqVtoQiXo6rLxlNx8KB0Y3b8zJuuSTjiSNjrqhEvd0QCGKxSzs3RSvCfIHqc5kdhXzdH48CEE5hQgYkrFw==", "integrity": "sha512-97POcpucME22ALdM8TqosGvNJWu6cNere0fE4NcHVhh0LXhuWyhMN5kviqNqeyZisDSK2EGd4ZqKUVxlQkxqDQ==",
"peer": true, "peer": true,
"requires": { "requires": {
"@koa/router": "^10.1.1", "@koa/router": "^10.1.1",
"@satorijs/core": "1.3.1", "@satorijs/core": "1.3.7",
"@types/koa": "*", "@types/koa": "*",
"@types/koa__router": "*", "@types/koa__router": "*",
"@types/ws": "^8.5.3", "@types/ws": "^8.5.3",
...@@ -8707,23 +8707,6 @@ ...@@ -8707,23 +8707,6 @@
"ws": "^8.8.1" "ws": "^8.8.1"
}, },
"dependencies": { "dependencies": {
"@tootallnate/once": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-2.0.0.tgz",
"integrity": "sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A==",
"peer": true
},
"http-proxy-agent": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-5.0.0.tgz",
"integrity": "sha512-n2hY8YdoRE1i7r6M0w9DIw5GgZN0G25P8zLCRQ8rjXtTU3vsNFBI/vWK/UIeE6g5MUUz6avwAPXmL6Fy9D/90w==",
"peer": true,
"requires": {
"@tootallnate/once": "2",
"agent-base": "6",
"debug": "4"
}
},
"path-to-regexp": { "path-to-regexp": {
"version": "6.2.1", "version": "6.2.1",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.2.1.tgz", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.2.1.tgz",
...@@ -8762,6 +8745,12 @@ ...@@ -8762,6 +8745,12 @@
"integrity": "sha512-OvjF+z51L3ov0OyAU0duzsYuvO01PH7x4t6DJx+guahgTnBHkhJdG7soQeTSFLWN3efnHyibZ4Z8l2EuWwJN3A==", "integrity": "sha512-OvjF+z51L3ov0OyAU0duzsYuvO01PH7x4t6DJx+guahgTnBHkhJdG7soQeTSFLWN3efnHyibZ4Z8l2EuWwJN3A==",
"peer": true "peer": true
}, },
"@tootallnate/once": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-2.0.0.tgz",
"integrity": "sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A==",
"peer": true
},
"@types/accepts": { "@types/accepts": {
"version": "1.3.5", "version": "1.3.5",
"resolved": "https://registry.npmjs.org/@types/accepts/-/accepts-1.3.5.tgz", "resolved": "https://registry.npmjs.org/@types/accepts/-/accepts-1.3.5.tgz",
...@@ -9750,9 +9739,9 @@ ...@@ -9750,9 +9739,9 @@
} }
}, },
"cordis-axios": { "cordis-axios": {
"version": "2.1.3", "version": "2.1.4",
"resolved": "https://registry.npmjs.org/cordis-axios/-/cordis-axios-2.1.3.tgz", "resolved": "https://registry.npmjs.org/cordis-axios/-/cordis-axios-2.1.4.tgz",
"integrity": "sha512-W6RCzZ4u+q/2D+BSAYV3aA3dMuz1bi+c9L1RI8g9SLaA5Z2QoaJ5zX1faIrS8y79AWtXm8joIGj+gzPVnvO8ww==", "integrity": "sha512-znwVVXxmvv3/RHY/5i9sDjmEGOrR0dki+QcfwawnrVlM5R8YqHwFLlZTapzbuP8pKvHjJ9GfkkQYwk5CaTFWQg==",
"peer": true, "peer": true,
"requires": { "requires": {
"axios": "^1.1.2", "axios": "^1.1.2",
...@@ -10735,6 +10724,17 @@ ...@@ -10735,6 +10724,17 @@
"toidentifier": "1.0.1" "toidentifier": "1.0.1"
} }
}, },
"http-proxy-agent": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-5.0.0.tgz",
"integrity": "sha512-n2hY8YdoRE1i7r6M0w9DIw5GgZN0G25P8zLCRQ8rjXtTU3vsNFBI/vWK/UIeE6g5MUUz6avwAPXmL6Fy9D/90w==",
"peer": true,
"requires": {
"@tootallnate/once": "2",
"agent-base": "6",
"debug": "4"
}
},
"https-proxy-agent": { "https-proxy-agent": {
"version": "5.0.1", "version": "5.0.1",
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz",
...@@ -11553,14 +11553,14 @@ ...@@ -11553,14 +11553,14 @@
} }
}, },
"koishi": { "koishi": {
"version": "4.9.7", "version": "4.10.1",
"resolved": "https://registry.npmjs.org/koishi/-/koishi-4.9.7.tgz", "resolved": "https://registry.npmjs.org/koishi/-/koishi-4.10.1.tgz",
"integrity": "sha512-InvvfPx5sqRkgOlTWksQu1dWjASCcf92guRGQmm+UIqZh0GBTJi+uFmpAMPA/E+nHOoLDOy/U9DVtpSPipi2+g==", "integrity": "sha512-nET+NfATO+99tNKasgPpyZzFv3kmjzrDmSyJmPlWDsokbjvouMIQHh6EGBiwLCipp7KKsQNZabB3FEFbwzL7Qg==",
"peer": true, "peer": true,
"requires": { "requires": {
"@koishijs/core": "^4.9.7", "@koishijs/core": "^4.10.1",
"@koishijs/utils": "^6.2.4", "@koishijs/utils": "^6.2.5",
"@satorijs/satori": "^1.3.1", "@satorijs/satori": "^1.3.7",
"file-type": "^16.5.4", "file-type": "^16.5.4",
"ns-require": "^1.1.4" "ns-require": "^1.1.4"
} }
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
"peerDependencies": { "peerDependencies": {
"@nestjs/common": "^9.0.3 || ^8.0.0", "@nestjs/common": "^9.0.3 || ^8.0.0",
"@nestjs/core": "^9.0.3 || ^8.0.0", "@nestjs/core": "^9.0.3 || ^8.0.0",
"koishi": "^4.9.7", "koishi": "^4.10.1",
"rxjs": "^7.5.5" "rxjs": "^7.5.5"
}, },
"devDependencies": { "devDependencies": {
......
...@@ -5,6 +5,7 @@ import { ...@@ -5,6 +5,7 @@ import {
Injectable, Injectable,
} from '@nestjs/common'; } from '@nestjs/common';
import { WsException } from '@nestjs/websockets'; import { WsException } from '@nestjs/websockets';
import { SessionError } from 'koishi';
import { KOISHI_MODULE_OPTIONS } from '../utility/koishi.constants'; import { KOISHI_MODULE_OPTIONS } from '../utility/koishi.constants';
import { KoishiModuleOptions } from '../utility/koishi.interfaces'; import { KoishiModuleOptions } from '../utility/koishi.interfaces';
...@@ -18,16 +19,19 @@ export class KoishiExceptionHandlerService extends ConsoleLogger { ...@@ -18,16 +19,19 @@ export class KoishiExceptionHandlerService extends ConsoleLogger {
} }
handleActionException(e: Error) { handleActionException(e: Error) {
if (e instanceof SessionError) {
console.log('session error');
throw e;
}
if (e instanceof HttpException || e instanceof WsException) { if (e instanceof HttpException || e instanceof WsException) {
return e.message; return e.message;
} else {
this.error(e.message, e.stack);
if (this.koishiModuleOptions.actionErrorMessage === '') {
return;
}
return (
this.koishiModuleOptions.actionErrorMessage ?? 'Internal Server Error'
);
} }
this.error(e.message, e.stack);
if (this.koishiModuleOptions.actionErrorMessage === '') {
return;
}
return (
this.koishiModuleOptions.actionErrorMessage ?? 'Internal Server Error'
);
} }
} }
import { HttpException } from '@nestjs/common';
import { WsException } from '@nestjs/websockets';
export function handleActionException(e: Error) {
if (e instanceof HttpException || e instanceof WsException) {
return e.message;
} else {
throw e;
}
}
...@@ -165,6 +165,16 @@ describe('Koishi in Nest.js', () => { ...@@ -165,6 +165,16 @@ describe('Koishi in Nest.js', () => {
); );
}); });
/*
it('should handle SessionError', () => {
const command = koishiApp.command('hoo');
expect(command).toBeDefined();
expect(command.execute({ options: { content: 'hoo' } })).resolves.toBe(
'hoo!',
);
});
*/
it('should work on template', () => { it('should work on template', () => {
const command = koishiApp.command('mii'); const command = koishiApp.command('mii');
expect(command).toBeDefined(); expect(command).toBeDefined();
......
import { Injectable, NotFoundException } from '@nestjs/common'; import { Injectable, NotFoundException } from '@nestjs/common';
import { KoishiCommandInterceptor } from '../../src/utility/koishi.interfaces'; import { KoishiCommandInterceptor } from '../../src/utility/koishi.interfaces';
import { Argv, Context } from 'koishi'; import { Argv, Context, SessionError } from 'koishi';
import { import {
CommandTemplate,
CommandUsage, CommandUsage,
OnGuild, OnGuild,
OnPlatform, OnPlatform,
...@@ -74,6 +75,12 @@ export class KoishiTestService { ...@@ -74,6 +75,12 @@ export class KoishiTestService {
throw new Error('bow!'); throw new Error('bow!');
} }
@UseCommand('hoo')
@CommandTemplate('.hoo', 'hoo!')
async onHoo() {
throw new SessionError('.hoo');
}
@UseCommand('moo') @UseCommand('moo')
@CommandInterceptors(MooInterceptor) @CommandInterceptors(MooInterceptor)
async onMoo() { async onMoo() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment