Skip to content

Commit 009432e

Browse files
committed
Better handling of syntax errors in Plain source.
1 parent 0da4c90 commit 009432e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

codeplain_REST_api.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,18 @@ class MissingResource(Exception):
2222
pass
2323

2424

25+
class PlainSyntaxError(Exception):
26+
pass
27+
28+
2529
class OnlyRelativeLinksAllowed(Exception):
2630
pass
2731

2832

33+
class LinkMustHaveTextSpecified(Exception):
34+
pass
35+
36+
2937
class CodeplainAPI:
3038

3139
def __init__(self, api_key):
@@ -67,9 +75,15 @@ def post_request(self, endpoint_url, headers, payload):
6775
if response_json["error_code"] == 'MissingResource':
6876
raise MissingResource(response_json['message'])
6977

78+
if response_json["error_code"] == 'PlainSyntaxError':
79+
raise PlainSyntaxError(response_json['message'])
80+
7081
if response_json["error_code"] == 'OnlyRelativeLinksAllowed':
7182
raise OnlyRelativeLinksAllowed(response_json['message'])
7283

84+
if response_json["error_code"] == 'LinkMustHaveTextSpecified':
85+
raise LinkMustHaveTextSpecified(response_json['message'])
86+
7387
response.raise_for_status()
7488

7589
return response_json

0 commit comments

Comments
 (0)