mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-09 13:56:23 +00:00
40c77e5928
* Initial commit. * Fix current test suite. * Fix keymanager api test. * Fix wss_sim. * Add more keystore_management tests. * Recover deleted isEmptyDir(). * Add `HttpHostUri` distinct type. Move keymanager calls away from rest_beacon_calls to rest_keymanager_calls. Add REST serialization of RemoteKeystore and Keystore object. Add tests for Remote Keystore management API. Add tests for Keystore management API (Add keystore). Fix serialzation issues. * Fix test to use HttpHostUri instead of Uri. * Add links to specification in comments. * Remove debugging echoes.
32 lines
1.3 KiB
Nim
32 lines
1.3 KiB
Nim
# Copyright (c) 2018-2022 Status Research & Development GmbH
|
|
# Licensed and distributed under either of
|
|
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
|
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
|
|
|
{.push raises: [Defect].}
|
|
|
|
import
|
|
chronos, presto/client, chronicles,
|
|
"."/[rest_types, eth2_rest_serialization]
|
|
|
|
export chronos, client, rest_types, eth2_rest_serialization
|
|
|
|
proc raiseGenericError*(resp: RestPlainResponse) {.
|
|
noreturn, raises: [RestError, Defect].} =
|
|
let error =
|
|
block:
|
|
let res = decodeBytes(RestGenericError, resp.data, resp.contentType)
|
|
if res.isErr():
|
|
let msg = "Incorrect response error format (" & $resp.status &
|
|
") [" & $res.error() & "]"
|
|
raise newException(RestError, msg)
|
|
res.get()
|
|
let msg = "Error response (" & $resp.status & ") [" & error.message & "]"
|
|
raise newException(RestError, msg)
|
|
|
|
proc raiseUnknownStatusError*(resp: RestPlainResponse) {.
|
|
noreturn, raises: [RestError, Defect].} =
|
|
let msg = "Unknown response status error (" & $resp.status & ")"
|
|
raise newException(RestError, msg)
|