mirror of
https://github.com/github/codeql-action.git
synced 2025-12-30 11:10:22 +08:00
Co-authored-by: Andrew Eisenberg <aeisenberg@github.com> Co-authored-by: Henry Mercer <henrymercer@github.com>
37 lines
1.1 KiB
JavaScript
37 lines
1.1 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.RpcError = void 0;
|
|
/**
|
|
* An error that occurred while calling a RPC method.
|
|
*/
|
|
class RpcError extends Error {
|
|
constructor(message, code = 'UNKNOWN', meta) {
|
|
super(message);
|
|
this.name = 'RpcError';
|
|
// see https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-2.html#example
|
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
this.code = code;
|
|
this.meta = meta !== null && meta !== void 0 ? meta : {};
|
|
}
|
|
toString() {
|
|
const l = [this.name + ': ' + this.message];
|
|
if (this.code) {
|
|
l.push('');
|
|
l.push('Code: ' + this.code);
|
|
}
|
|
if (this.serviceName && this.methodName) {
|
|
l.push('Method: ' + this.serviceName + '/' + this.methodName);
|
|
}
|
|
let m = Object.entries(this.meta);
|
|
if (m.length) {
|
|
l.push('');
|
|
l.push('Meta:');
|
|
for (let [k, v] of m) {
|
|
l.push(` ${k}: ${v}`);
|
|
}
|
|
}
|
|
return l.join('\n');
|
|
}
|
|
}
|
|
exports.RpcError = RpcError;
|