Skip to content
Snippets Groups Projects
Commit 6078a91d authored by Moul's avatar Moul
Browse files

[mypy] #163: verify: exit when failing to retrieve a chunk

Use urllib.error.HTTPError
Could fix #351, since 'None' (nothing) used to be returned
and the error was:
TypeError: 'NoneType' object is not subscriptable
parent 0df91033
No related branches found
No related tags found
No related merge requests found
......@@ -15,11 +15,11 @@
import logging
from typing import List
from urllib.error import HTTPError
from click import INT, argument, command, progressbar
from duniterpy.api import bma
from duniterpy.api.client import Client
from duniterpy.api.errors import DuniterError
from duniterpy.documents import Block
from silkaj.constants import BMA_MAX_BLOCKS_CHUNK_SIZE
......@@ -81,9 +81,11 @@ def get_chunk_size(
def get_chunk(client: Client, chunk_size: int, chunk_from: int) -> List:
try:
return client(bma.blockchain.blocks, chunk_size, chunk_from)
except DuniterError as error:
logging.error(error)
chunk = client(bma.blockchain.blocks, chunk_size, chunk_from)
except HTTPError as e:
logging.error(e)
message_exit("Error: Network error to get chunck")
return chunk
def verify_block_signature(invalid_blocks_signatures: List[int], block: Block) -> None:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment