跳转到主要内容

类:MCPAuthBearerAuthError

当使用 Bearer 令牌进行认证 (Authentication) 时出现问题时抛出的错误。

继承自​

构造函数​

构造函数​

new MCPAuthBearerAuthError(code: BearerAuthErrorCode, cause?: MCPAuthBearerAuthErrorDetails): MCPAuthBearerAuthError;

参数​

code​

BearerAuthErrorCode

cause?​

MCPAuthBearerAuthErrorDetails

返回值​

MCPAuthBearerAuthError

重写自​

MCPAuthError.constructor

属性​

cause?​

readonly optional cause: MCPAuthBearerAuthErrorDetails;

继承自​

MCPAuthError.cause


code​

readonly code: BearerAuthErrorCode;

错误码,采用 snake_case 格式。

继承自​

MCPAuthError.code


message​

message: string;

继承自​

MCPAuthError.message


name​

name: string = 'MCPAuthBearerAuthError';

重写自​

MCPAuthError.name


stack?​

optional stack: string;

继承自​

MCPAuthError.stack


prepareStackTrace()?​

static optional prepareStackTrace: (err: Error, stackTraces: CallSite[]) => any;

可选的堆栈跟踪格式化重写

参数​

err​

Error

stackTraces​

CallSite[]

返回值​

any

参考​

https://v8.dev/docs/stack-trace-api#customizing-stack-traces

继承自​

MCPAuthError.prepareStackTrace


stackTraceLimit​

static stackTraceLimit: number;

继承自​

MCPAuthError.stackTraceLimit

方法​

toJson()​

toJson(showCause: boolean): Record<string, unknown>;

将错误转换为适合 HTTP 响应的 JSON 格式。

参数​

showCause​

boolean = false

是否在 JSON 响应中包含错误原因。 默认为 false。

返回值​

Record<string, unknown>

重写自​

MCPAuthError.toJson


captureStackTrace()​

static captureStackTrace(targetObject: object, constructorOpt?: Function): void;

在目标对象上创建 .stack 属性

参数​

targetObject​

object

constructorOpt?​

Function

返回值​

void

继承自​

MCPAuthError.captureStackTrace