Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error links #55

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 new endpoints
kevinwon96 committed Jul 27, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 2cc49b3716e2280542bfb9ca0483a53af3083553
14 changes: 14 additions & 0 deletions pybit/_helpers.py
Original file line number Diff line number Diff line change
@@ -36,3 +36,17 @@ def make_public_kwargs(private_kwargs):
public_kwargs.pop("api_key", "")
public_kwargs.pop("api_secret", "")
return public_kwargs

def error_link(path, number):
if "spot" in path:
number = -1*number
return f" https://bybit-exchange.github.io/docs/spot/#{number}"
elif "account_asset" in path: # account asset
return f" https://bybit-exchange.github.io/docs/account_asset/#{number}",
elif "usdc" in path: # USDC
if "option" in path: # option
return f" https://bybit-exchange.github.io/docs/usdc/option/#{number}"
else: # perpetual
return f" https://bybit-exchange.github.io/docs/usdc/perpetual/#{number}"
else: # inverse perpetual, USDT perpetual, inverse futures
return f" https://bybit-exchange.github.io/docs/inverse/#{number}"
4 changes: 3 additions & 1 deletion pybit/_http_manager.py
Original file line number Diff line number Diff line change
@@ -383,9 +383,11 @@ def _submit_request(self, method=None, path=None, query=None, auth=False):
pass

else:
error_link = _helpers.error_link(path, s_json[ret_code])

raise InvalidRequestError(
request=f"{method} {path}: {req_params}",
message=s_json[ret_msg],
message=s_json[ret_msg] + error_link,
status_code=s_json[ret_code],
time=dt.utcnow().strftime("%H:%M:%S")
)