trailsjs / trailpack-hapi

:package: Hapi.js Trailpack
MIT License
19 stars 9 forks source link

Wrong footprint error message #30

Open jaumard opened 8 years ago

jaumard commented 8 years ago

If we call a route like /api/v1/default/toto, I have this error :

debug: [FootprintController] (find) model = default , criteria = {} info options =
Debug: internal, implementation, error 
    TypeError: Uncaught error: Cannot read property 'findOne' of undefined
    at FootprintService.find (/Users/jaumard/Downloads/testTrails/node_modules/trailpack-waterline/api/services/FootprintService.js:46:20)
    at FootprintController.find (/Users/jaumard/Downloads/testTrails/node_modules/trailpack-hapi/api/controllers/FootprintController.js:46:35)
    at result.method.finalize (/Users/jaumard/Downloads/testTrails/node_modules/hapi/lib/handler.js:215:20)
    at Object.exports.execute.internals.prerequisites.internals.handler.callback [as handler] (/Users/jaumard/Downloads/testTrails/node_modules/hapi/lib/handler.js:96:36)
    at /Users/jaumard/Downloads/testTrails/node_modules/hapi/lib/handler.js:63:26
    at done (/Users/jaumard/Downloads/testTrails/node_modules/hapi/node_modules/items/lib/index.js:31:25)
    at done (/Users/jaumard/Downloads/testTrails/node_modules/hapi/node_modules/items/lib/index.js:63:25)
    at /Users/jaumard/Downloads/testTrails/node_modules/hapi/lib/handler.js:49:28
    at finalize (/Users/jaumard/Downloads/testTrails/node_modules/hapi/lib/handler.js:281:20)
    at wrapped (/Users/jaumard/Downloads/testTrails/node_modules/hapi/node_modules/hoek/lib/index.js:867:20)
    at internals.Response._prepare.internals.Response._processPrepare.next [as _processPrepare] (/Users/jaumard/Downloads/testTrails/node_modules/hapi/lib/response.js:448:16)
    at internals.Response._prepare.next [as _prepare] (/Users/jaumard/Downloads/testTrails/node_modules/hapi/lib/response.js:387:21)
    at /Users/jaumard/Downloads/testTrails/node_modules/hapi/lib/reply.js:151:22
    at doNTCallback0 (node.js:408:9)
    at process._tickDomainCallback (node.js:378:13)

A better error message can be send like no model default or just 500 server error

enten commented 8 years ago

@context trailpack-waterline/api/Services/FootprintService

I guess that this error is due to an undefined reference when a model is recovered from app.orm or app.packs.waterline.orm.collections in FootprintService (line 38 for example).

All FootprintService methods can throws similar error (model not found).

Why there are no check to be sure if a model exists?

weyj4 commented 8 years ago

@jaumard is this still an issue or can we close?

jaumard commented 8 years ago

Still an issue but not for hapi I think because it have to be fix/check on trailpack-router or trailpack-footprints or each trailpack-datastore Like @enten say there is no check to see if the model exist. Where we could put this issue ?

jaumard commented 8 years ago

@weyj4 Here is how I fix this for Express and Sequelize On Footprint service (sequelize) : https://github.com/trailsjs/trailpack-sequelize/blob/master/api/services/FootprintService.js#L27 On Footprint controller (express) : https://github.com/trailsjs/trailpack-express/blob/master/api/controllers/FootprintController.js#L25

With this Footprint controller web server doesn't send a 500 whatever the server is (as hapi do actually).

mautematico commented 8 years ago

Is there a way I can help with this? I have particular interest on fixing the king of errors jaumard refers to on his last comment. Related to this: https://github.com/trailsjs/trailpack-sequelize/pull/23

SrilakshmiGodugunuri7 commented 4 years ago

How to pass criteria = { column is not null} ?