deta / deta-python

deta's official sdk
https://deta.space/docs/en/build/reference/sdk/base
MIT License
153 stars 26 forks source link

Don't raise with the Exception class #66

Closed edmondchuc closed 2 years ago

edmondchuc commented 2 years ago

In a few places in deta/base.py exceptions are raised with the Exception class.

See https://github.com/deta/deta-python/blob/5e68173ffea4b3dd2c3d75fadda4e3c9854d3199/deta/base.py.

https://github.com/deta/deta-python/blob/5e68173ffea4b3dd2c3d75fadda4e3c9854d3199/deta/base.py#L134

https://github.com/deta/deta-python/blob/5e68173ffea4b3dd2c3d75fadda4e3c9854d3199/deta/base.py#L272

It'd be better practice if custom exceptions were defined and derived from the general Exception class.

saadmanrafat commented 2 years ago

Using Built-in Exceptions would be ideal than writing custom Exceptions. Simple solution would be to use the built-in KeyError Exception. Refactoring the codebase with Custom Exceptions might make it harder for the maintainers, who have their own flow -- just something to think about before creating a PR.

abdelhai commented 2 years ago

hi @edmondchuc, does PR #69 solve this issue for you?