(message, error)
| 92 | const clientId = `client#${nextClientId++}`; |
| 93 | |
| 94 | function handleCaughtError(message, error) { |
| 95 | const errorMessage = { |
| 96 | id: message.id, |
| 97 | method: message.method, |
| 98 | target: message.target, |
| 99 | error: message.error === undefined ? 'undefined' : 'defined', |
| 100 | params: message.params === undefined ? 'undefined' : 'defined', |
| 101 | result: message.result === undefined ? 'undefined' : 'defined', |
| 102 | }; |
| 103 | |
| 104 | if (message.id === undefined) { |
| 105 | console.error( |
| 106 | `Handling message from ${clientId} failed with:\n${error}\n` + |
| 107 | `message:\n${JSON.stringify(errorMessage)}`); |
| 108 | } else { |
| 109 | try { |
| 110 | clientWs.send(JSON.stringify({ |
| 111 | version: PROTOCOL_VERSION, |
| 112 | error: error, |
| 113 | id: message.id, |
| 114 | })); |
| 115 | } catch (e) { |
| 116 | console.error(`Failed to reply to ${clientId} with error:\n${error}` + |
| 117 | `\nmessage:\n${JSON.stringify(errorMessage)}` + |
| 118 | `\ndue to error: ${e.toString()}`); |
| 119 | } |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | function handleServerRequest(message) { |
| 124 | let result = null; |
no test coverage detected
searching dependent graphs…