Skip to content

Commit

Permalink
fix(workers/google): Unsafe exception catching refactored
Browse files Browse the repository at this point in the history
  • Loading branch information
RezaRahemtola committed Oct 20, 2023
1 parent b0d2b1c commit 1333c2d
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 24 deletions.
4 changes: 2 additions & 2 deletions backend/workers/google/src/classrooms/create_course.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def create_course():
with grpc.insecure_channel(target) as channel:
AreaBackServiceStub(channel).OnError(JobError(identifier=args["identifier"], error=str(error), isAuthError=True))
exit(1)
except:
except Exception as e:
with grpc.insecure_channel(target) as channel:
AreaBackServiceStub(channel).OnError(
JobError(identifier=args["identifier"], error=str(sys.exc_info()[0]), isAuthError=False))
exit(1)
raise e
4 changes: 2 additions & 2 deletions backend/workers/google/src/contacts/create_contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ def create_contact():
with grpc.insecure_channel(target) as channel:
AreaBackServiceStub(channel).OnError(JobError(identifier=args["identifier"], error=str(error), isAuthError=True))
exit(1)
except:
except Exception as e:
with grpc.insecure_channel(target) as channel:
AreaBackServiceStub(channel).OnError(
JobError(identifier=args["identifier"], error=str(sys.exc_info()[0]), isAuthError=False))
exit(1)
raise e
4 changes: 2 additions & 2 deletions backend/workers/google/src/docs/create_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def create_document():
with grpc.insecure_channel(target) as channel:
AreaBackServiceStub(channel).OnError(JobError(identifier=args["identifier"], error=str(error), isAuthError=True))
exit(1)
except:
except Exception as e:
with grpc.insecure_channel(target) as channel:
AreaBackServiceStub(channel).OnError(
JobError(identifier=args["identifier"], error=str(sys.exc_info()[0]), isAuthError=False))
exit(1)
raise e
4 changes: 2 additions & 2 deletions backend/workers/google/src/forms/create_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ def create_form():
with grpc.insecure_channel(target) as channel:
AreaBackServiceStub(channel).OnError(JobError(identifier=args["identifier"], error=str(error), isAuthError=True))
exit(1)
except:
except Exception as e:
with grpc.insecure_channel(target) as channel:
AreaBackServiceStub(channel).OnError(
JobError(identifier=args["identifier"], error=str(sys.exc_info()[0]), isAuthError=False))
exit(1)
raise e
4 changes: 2 additions & 2 deletions backend/workers/google/src/gmail/create_draft.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ def create_draft():
with grpc.insecure_channel(target) as channel:
AreaBackServiceStub(channel).OnError(JobError(identifier=args["identifier"], error=str(error), isAuthError=True))
exit(1)
except:
except Exception as e:
with grpc.insecure_channel(target) as channel:
AreaBackServiceStub(channel).OnError(
JobError(identifier=args["identifier"], error=str(sys.exc_info()[0]), isAuthError=False))
exit(1)
raise e
4 changes: 2 additions & 2 deletions backend/workers/google/src/gmail/send_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ def send_email():
with grpc.insecure_channel(target) as channel:
AreaBackServiceStub(channel).OnError(JobError(identifier=args["identifier"], error=str(error), isAuthError=True))
exit(1)
except:
except Exception as e:
with grpc.insecure_channel(target) as channel:
AreaBackServiceStub(channel).OnError(
JobError(identifier=args["identifier"], error=str(sys.exc_info()[0]), isAuthError=False))
exit(1)
raise e
9 changes: 4 additions & 5 deletions backend/workers/google/src/gmail/update_signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,10 @@ def update_signature():

except RefreshError as error:
with grpc.insecure_channel(target) as channel:
AreaBackServiceStub(channel).OnError(JobError(identifier=identifier, error=str(error), isAuthError=True))
AreaBackServiceStub(channel).OnError(JobError(identifier=args["identifier"], error=str(error), isAuthError=True))
exit(1)

except:
except Exception as e:
with grpc.insecure_channel(target) as channel:
AreaBackServiceStub(channel).OnError(
JobError(identifier=identifier, error=str(sys.exc_info()[0]), isAuthError=False))
exit(1)
JobError(identifier=args["identifier"], error=str(sys.exc_info()[0]), isAuthError=False))
raise e
4 changes: 2 additions & 2 deletions backend/workers/google/src/slides/create_slide.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ def create_slide():
with grpc.insecure_channel(target) as channel:
AreaBackServiceStub(channel).OnError(JobError(identifier=args["identifier"], error=str(error), isAuthError=True))
exit(1)
except:
except Exception as e:
with grpc.insecure_channel(target) as channel:
AreaBackServiceStub(channel).OnError(
JobError(identifier=args["identifier"], error=str(sys.exc_info()[0]), isAuthError=False))
exit(1)
raise e
4 changes: 2 additions & 2 deletions backend/workers/google/src/spreadsheets/create_spreadsheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ def create_spreadsheet():
with grpc.insecure_channel(target) as channel:
AreaBackServiceStub(channel).OnError(JobError(identifier=args["identifier"], error=str(error), isAuthError=True))
exit(1)
except:
except Exception as e:
with grpc.insecure_channel(target) as channel:
AreaBackServiceStub(channel).OnError(
JobError(identifier=args["identifier"], error=str(sys.exc_info()[0]), isAuthError=False))
exit(1)
raise e
5 changes: 2 additions & 3 deletions backend/workers/google/src/youtube/create_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ def create_comment():
with grpc.insecure_channel(target) as channel:
AreaBackServiceStub(channel).OnError(JobError(identifier=args["identifier"], error=str(error), isAuthError=True))
exit(1)

except:
except Exception as e:
with grpc.insecure_channel(target) as channel:
AreaBackServiceStub(channel).OnError(
JobError(identifier=args["identifier"], error=str(sys.exc_info()[0]), isAuthError=False))
exit(1)
raise e

0 comments on commit 1333c2d

Please sign in to comment.