Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ulixee
GitHub Repository: ulixee/secret-agent
Path: blob/main/puppet-chrome/lib/ProtocolError.ts
1028 views
1
export default class ProtocolError extends Error {
2
public remoteError: { message: string; data: any; code?: number };
3
public method: string;
4
constructor(
5
stack: string,
6
method: string,
7
remoteError: { message: string; data: any; code?: number },
8
) {
9
let message = `${method}: ${remoteError.message}`;
10
if ('data' in remoteError) {
11
if (typeof remoteError.data === 'string') {
12
message += ` ${remoteError.data}`;
13
} else {
14
message += ` ${JSON.stringify(remoteError.data)}`;
15
}
16
}
17
super(message);
18
this.name = 'ProtocolError';
19
this.method = method;
20
this.stack = stack;
21
this.stack = `${this.name}: ${this.message}\n${stack}`;
22
this.remoteError = remoteError;
23
}
24
}
25
26