ForestAdmin / forest-express

🧱 Dependency of Express Lianas for Forest Admin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Requiring models may fail silently

guillaumervls opened this issue · comments

Hi and thanks for your work !

Why is the require call for the models wrapped in an "ignore errors" try/catch ?

forest-express/index.js

Lines 27 to 29 in ed4e501

try {
require(path.join(modelsDir, file));
} catch (error) { }

Am I missing something ?

Cheers

Hi @guillaumervls, I didn't really look into the code history so I don't really have the answer to your question.

Do you think it would be better with explicit errors?
I don't think that users "fall" in this catch a lot. Having an error here means that one of your models contains error, am I wrong?
If you expect Forest to show you these errors (which is not the primary goal), then you're right we could display an explicit error message here.

Thanks for your answer.

Yes, I think you're right when you say it's not Forest's job to show errors in models, and I agree that it won't affect many users. (BTW the way I ran into this was : I was just trying out Forest and there was a typo in a test model (I wrote too quicky) => it didn't appear in Forest). Anyway I found this catchall statement, and since it's generally not a good idea to have these in released code, I just wondered if there was a specific reason for it...

Thanks for the confirmation, then we should display an error message for each model that cannot be required properly to help developers.

The improvement has been released.