Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use exception_page shard #991

Merged
merged 6 commits into from
Dec 13, 2018
Merged

Use exception_page shard #991

merged 6 commits into from
Dec 13, 2018

Conversation

dwightwatson
Copy link
Contributor

Description of the Change

Hi there - this is an attempted re-implementation of #864 but using the exception_page shard that was created out of it. Let me first confess that I'm very new to Crystal and Amber so this likely isn't perfect, but it is working.

image

What I'm not positive for - and would appreciate some guidance on - is how to ensure this won't be displayed in a production environment. I haven't quite worked out how to get Amber running in production mode on my local machine so haven't been able to test it.

Alternate Designs

I customised the page with the Amber logo, project URL and brand colours. It's just a nice feel versus the stock standard layout.

Benefits

Very pretty exception pages which brings us into line with other Crystal frameworks like Kemal and Lucky.

Possible Drawbacks

It does introduce another dependency, but if exception_page is fairly standard across frameworks then it shouldn't be too much of a concern.

@dwightwatson dwightwatson reopened this Dec 7, 2018
@faustinoaq faustinoaq requested a review from a team December 8, 2018 08:47
@faustinoaq
Copy link
Contributor

@dwightwatson Very nice! I haven't had enough time to work in this, Thank you so much! 👍

What I'm not positive for - and would appreciate some guidance on - is how to ensure this won't be displayed in a production environment.

Check #274, I managed to get Exception pages working on 3 conditions:

  1. Amber::Error::Pipe is disabled and shows basic plain text error message.
  2. Amber::Error::Pipe is enabled and shows this development template (default)
  3. Amber::Error::Pipe is enabled and error_controller.cr is modified to get customized error pages.

Maybe we can use Amber.env.development? to ensure this page works only on development, WDYT?

@dwightwatson
Copy link
Contributor Author

Thanks for the additional context - good to get a better understanding of how Amber all fits together.

I've had a crack at breaking out a html_response method that will only return the new error page in development, otherwise return the existing plain HTML response. Is this the sort of implementation you were looking for?

@drujensen
Copy link
Member

@dwightwatson @faustinoaq should this be included in the amber base controller or should this shard be injected in the end users project via the generators so they can handle how it works?

@dwightwatson
Copy link
Contributor Author

That didn't occur to me - it should probably be a development dependency too. A quick look into that suggests that only development dependencies in the root shard.yml file are installed - is that correct? In that case I suppose it would have to be injected in the end user's project.

@dwightwatson
Copy link
Contributor Author

Do you have any additional feedback on this one in order to get it merged in?

@drujensen
Copy link
Member

Wait, we have amber g error already. I may be confused as to what this is for. @faustinoaq can you provide some guidance here? I think I am missing something.

https://github.com/amberframework/amber/tree/master/src/amber/cli/templates

@faustinoaq
Copy link
Contributor

@drujensen
Copy link
Member

@faustinoaq 👍

@dwightwatson Based on @faustinoaq response, I was wrong to ask to have you move the shard to the template. Can you move it back? :sorry:

@drujensen drujensen merged commit 2cf39e7 into amberframework:master Dec 13, 2018
@drujensen
Copy link
Member

@dwightwatson thanks for this contribution. I will look into the shard location and see which is best.

@dwightwatson
Copy link
Contributor Author

Apologies for not getting back to this sooner, was travelling for work. Thanks for sorting it out 😄

@dwightwatson dwightwatson deleted the exception_page branch December 13, 2018 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants