sailorproject / sailor

A Lua MVC Web Framework.
MIT License
921 stars 125 forks source link

fix: return early from Page:render if no filename #108

Closed luisbg closed 8 years ago

luisbg commented 8 years ago

If filename is nil there is no use for setting the src, we should return early.

luisbg commented 8 years ago

I can add that error printing when the controller is missing if you tell me how/where you want it printed :smile:

Etiene commented 8 years ago

Yea, I think it's best to add already some kind of error message :) An error("Your message") should do :)

luisbg commented 8 years ago

Nice! error() shows a page using the default template showing the error and stack trace. Neat.

Etiene commented 8 years ago

What's missing in this case is not the controller, but the view file. Maybe this would be better? error("Could not find view file: "..dir.."/"..filename)

luisbg commented 8 years ago

You are right. That gives a more verbose error.

Fixing it now.

Etiene commented 8 years ago

Oh wait! Guess we both weren't paying attention. If filename is nil, it won't concatenate x) This is not about not finding the view file, but when a view name is not passed... sorry... Maybe error("No view name available.") or error("A view name is required.") ?

luisbg commented 8 years ago

LOL! Right, if filename is nil it won't help in the concatenation.

Etiene commented 8 years ago

but it filename name is nil there is no filename to concatenate with the error message :)

luisbg commented 8 years ago

ooops, you replied when I was editing.

I realized this just after my last comment. Gulps (shame)

Etiene commented 8 years ago

don't worry, I made the same mistake xD

luisbg commented 8 years ago

Thanks Etiene! Enjoy your Friday night :beers: