Skip to content

Commit c9fcac5

Browse files
committed
Fix more errors
1 parent 1fc1d94 commit c9fcac5

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

plugins/backend/feedbin/feedbinAPI.vala

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -68,24 +68,22 @@ public class FeedbinAPI : Object {
6868
message.set_request_body_from_bytes (null, new Bytes (input.data));
6969
}
7070

71-
m_session.send_and_read(message);
72-
var status = message.status_code;
73-
if(status < 200 || status >= 400)
74-
{
75-
switch(status)
76-
{
77-
case Soup.Status.CANT_RESOLVE:
78-
case Soup.Status.CANT_RESOLVE_PROXY:
79-
case Soup.Status.CANT_CONNECT:
80-
case Soup.Status.CANT_CONNECT_PROXY:
81-
throw new FeedbinError.NO_CONNECTION(@"Connection to $m_base_uri failed");
82-
case Soup.Status.UNAUTHORIZED:
83-
throw new FeedbinError.NOT_AUTHORIZED(@"Not authorized to $method $path");
84-
case Soup.Status.NOT_FOUND:
85-
throw new FeedbinError.NOT_FOUND(@"$method $path not found");
86-
}
87-
string phrase = Soup.Status.get_phrase(status);
88-
throw new FeedbinError.UNKNOWN_ERROR(@"Unexpected status $status ($phrase) for $method $path");
71+
try {
72+
m_session.send_and_read(message);
73+
var status = message.status_code;
74+
if (status < 200 || status >= 400) {
75+
switch (status)
76+
{
77+
case Soup.Status.UNAUTHORIZED:
78+
throw new FeedbinError.NOT_AUTHORIZED(@"Not authorized to $method $path");
79+
case Soup.Status.NOT_FOUND:
80+
throw new FeedbinError.NOT_FOUND(@"$method $path not found");
81+
}
82+
string phrase = Soup.Status.get_phrase(status);
83+
throw new FeedbinError.UNKNOWN_ERROR(@"Unexpected status $status ($phrase) for $method $path");
84+
}
85+
} catch (Error e) {
86+
throw new FeedbinError.NO_CONNECTION (@"Connection to $m_base_uri failed");
8987
}
9088
return message;
9189
}
@@ -128,7 +126,7 @@ public class FeedbinAPI : Object {
128126
private static Json.Node parse_json(Soup.Message response) throws FeedbinError
129127
{
130128
var method = response.method;
131-
var uri = response.uri.to_string(false);
129+
var uri = response.uri.to_string ();
132130
string content = (string)response.response_body.flatten().data;
133131
if(content == null)
134132
{
@@ -142,7 +140,7 @@ public class FeedbinAPI : Object {
142140
}
143141
catch (Error e)
144142
{
145-
throw new FeedbinError.INVALID_FORMAT(@"$method $uri returned invalid JSON: " + e.message + "\nContent is: $content");
143+
throw new FeedbinError.INVALID_FORMAT (@"$method $uri returned invalid JSON: $(e.message)\nContent is: $content");
146144
}
147145
return parser.get_root();
148146
}

0 commit comments

Comments
 (0)