Skip to content

Commit

Permalink
Merge pull request okfn-brasil#510 from luizfzs/luizfzs-handle-error-…
Browse files Browse the repository at this point in the history
…when-reimbursement-url-not-found

Add HTTPError handling when ReimbursementsURL doesn't exist
  • Loading branch information
sergiomario authored Jan 2, 2020
2 parents 12d23e8 + 6cd58b3 commit d1b4e16
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion rosie/rosie/chamber_of_deputies/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import numpy as np
import pandas as pd
from urllib.error import HTTPError

from serenata_toolbox.chamber_of_deputies.reimbursements import Reimbursements
from serenata_toolbox.datasets import fetch
Expand Down Expand Up @@ -85,7 +86,10 @@ def update_reimbursements(self, years=None):

for year in years:
self.log.info(f'Updating reimbursements from {year}')
Reimbursements(year, self.path)()
try:
Reimbursements(year, self.path)()
except HTTPError as e:
self.log.error(f'Could not update Reimbursements from year {year}: {e} - {e.filename}')

def prepare_dataset(self, df):
self.rename_categories(df)
Expand Down

0 comments on commit d1b4e16

Please sign in to comment.