小编Luc*_*cas的帖子

NestJS 异常过滤器不应该捕获事件发射器错误吗?

我正在重构的 NestJS 应用程序上运行一些手动测试,并且刚刚从 Nest 的全局异常过滤器中发现了奇怪的行为。创建该项目的开发人员使用它作为异常过滤器:


import {
  ExceptionFilter,
  Catch,
  ArgumentsHost,
  HttpException,
  HttpStatus,
} from '@nestjs/common';
import { HttpAdapterHost } from '@nestjs/core';
import { LoggerService } from '../../config/logger.service';

@Catch()
export class GlobalExceptionsFilter implements ExceptionFilter {
  constructor(
    private readonly httpAdapterHost: HttpAdapterHost,
    private readonly logger: LoggerService,
  ) {}

  catch(exception: Error, host: ArgumentsHost): void {
    const { httpAdapter } = this.httpAdapterHost;

    const ctx = host.switchToHttp();

    const httpStatus =
      exception instanceof HttpException
        ? exception.getStatus()
        : HttpStatus.INTERNAL_SERVER_ERROR;

    const responseBody = {
      statusCode: httpStatus,
      path: httpAdapter.getRequestUrl(ctx.getRequest()),
      cause: …
Run Code Online (Sandbox Code Playgroud)

node.js typescript nestjs

5
推荐指数
0
解决办法
625
查看次数

Git 未检测到文件名大小写更改

我目前面临一个相当奇怪的问题,git 没有在我的文件中查找大小写更改。我有app.module.tsoutside.dto.ts我已将它们更改为App.module.tsOutside.dto.ts

我不确定 git 是否没有选择这些更改,或者这是否是我的存储库的一个非常具体的问题,但我的存储库仍然使用小写文件名,即使我已经使用不同的文件名大小写多次提交。

很确定这没有什么区别,但由于我从未在 GitHub 上看到过这种情况,所以我认为提及我正在使用 Azure Repo 也没什么坏处。

git github azure-repos

3
推荐指数
1
解决办法
2284
查看次数

标签 统计

azure-repos ×1

git ×1

github ×1

nestjs ×1

node.js ×1

typescript ×1