initial commit
This commit is contained in:
27
src/handlers/error.ts
Normal file
27
src/handlers/error.ts
Normal file
@ -0,0 +1,27 @@
|
||||
import { APIError, MessageContext } from "vk-io";
|
||||
import { Composer } from "../composer";
|
||||
import { logger } from "../logger";
|
||||
|
||||
export const composer = new Composer<MessageContext>();
|
||||
|
||||
composer.use(async (ctx, next) => {
|
||||
try {
|
||||
await next();
|
||||
} catch (err) {
|
||||
logger.error(err);
|
||||
}
|
||||
});
|
||||
|
||||
composer.use(async (ctx, next) => {
|
||||
try {
|
||||
await next();
|
||||
} catch (err) {
|
||||
if (err instanceof APIError && err.code === 917) {
|
||||
logger.error('no access to the chat');
|
||||
await ctx.send('хачю доступ к чату :=(');
|
||||
return;
|
||||
}
|
||||
|
||||
throw err;
|
||||
}
|
||||
});
|
Reference in New Issue
Block a user