Skip to content

Commit

Permalink
fix errors format
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonPuko committed Dec 16, 2016
1 parent 631a5bb commit 1047fec
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/controllers/DevicesController.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ class DevicesController extends Controller {

return this.ok({ result: varValue });
} catch (error) {
if (error.indexOf && error.indexOf('Variable not found') >= 0) {
const errorMessage = error.message;
if (errorMessage.indexOf('Variable not found') >= 0) {
throw new HttpError('Variable not found', 404);
}
throw error;
Expand Down Expand Up @@ -145,7 +146,8 @@ class DevicesController extends Controller {
);
return this.ok(deviceToAPI(device, result));
} catch (error) {
if (error.indexOf && error.indexOf('Unknown Function') >= 0) {
const errorMessage = error.message;
if (errorMessage.indexOf('Unknown Function') >= 0) {
throw new HttpError('Function not found', 404);
}
throw error;
Expand Down

0 comments on commit 1047fec

Please sign in to comment.