Skip to content

Commit

Permalink
Removed handleError function - instead looking at using serializer.ts…
Browse files Browse the repository at this point in the history
… functions instead (wip)
  • Loading branch information
MKHenson committed May 4, 2016
1 parent 798c335 commit e7019fd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 37 deletions.
25 changes: 5 additions & 20 deletions dist/controllers/bucket-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,9 @@ class BucketController extends controller_1.Controller {
router.put("/files/:file/rename-file", [permission_controller_1.requireUser, this.renameFile.bind(this)]);
router.put("/files/:id/make-public", [permission_controller_1.requireUser, this.makePublic.bind(this)]);
router.put("/files/:id/make-private", [permission_controller_1.requireUser, this.makePrivate.bind(this)]);
router.use(this.handleError);
// Register the path
e.use(`${config.apiPrefix}`, router);
}
/**
* Catches any and all requests that fell through
* @param {any} err
* @param {express.Request} req
* @param {express.Response} res
* @param {Function} next
*/
handleError(err, req, res, next) {
winston.error("ERROR CAUGHT!: " + err.toString(), { process: process.pid });
res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify({ message: err.toString(), error: true }));
}
;
/**
* Makes sure the target user exists and the numeric value specified is valid
* @param {express.Request} req
Expand Down Expand Up @@ -285,12 +271,11 @@ class BucketController extends controller_1.Controller {
data: stats
}));
}).catch(function (err) {
throw err;
// winston.error(err.toString(), { process: process.pid });
// return res.end(JSON.stringify(<users.IResponse>{
// message: err.toString(),
// error: true
// }));
winston.error(err.toString(), { process: process.pid });
return res.end(JSON.stringify({
message: err.toString(),
error: true
}));
});
}
/**
Expand Down
17 changes: 0 additions & 17 deletions src/controllers/bucket-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import * as validator from "validator";
import * as compression from "compression";
import * as winston from "winston";
import * as gcloud from "gcloud";

import {CommsController} from "./comms-controller";
import {EventType} from "../socket-event-types";
import * as def from "webinate-users";
Expand Down Expand Up @@ -68,26 +67,10 @@ export class BucketController extends Controller
router.put("/files/:id/make-public", <any>[requireUser, this.makePublic.bind(this)]);
router.put("/files/:id/make-private", <any>[requireUser, this.makePrivate.bind(this)]);

router.use(this.handleError);

// Register the path
e.use(`${config.apiPrefix}`, router);
}

/**
* Catches any and all requests that fell through
* @param {any} err
* @param {express.Request} req
* @param {express.Response} res
* @param {Function} next
*/
handleError(err: any, req: express.Request, res: express.Response, next: Function): any
{
winston.error( err.toString(), { process: process.pid });
res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify(<users.IResponse>{ message: err.toString(), error: true }));
};

/**
* Makes sure the target user exists and the numeric value specified is valid
* @param {express.Request} req
Expand Down

0 comments on commit e7019fd

Please sign in to comment.