NancyFx how to remove the tumbeast from errors - nancy

I do like the NancyFX error custom page. Unfortunately an exigent customer prefer not to see the green monster besides the error. Is there some way to just remove the image from the almost perfect nancyfx error message page?

You implement an IStatusCodeHandler and handle the status codes you want (like 404 and 500) by returning a response for them. If you need to render a view, take a dependency on the IViewRenderer and off you go =)

Related

Is there a way to handle URIError in React?

Some days ago I was working on an issue for my job where a page on React couldn't "catch" an error when someone tried to navigate using a bad URL that had the percentage sign (%) that can't be decoded.
The React project uses react-router-dom to handle navigation by showing different views when accessing different URL's (it even has a 404 route when it has no matching routes), and the struture looks very similar to React Router's 404 example, here's the link where you can try for yourself adding /% to the URL from the sandbox's browser and understand in a better way the problem.
In my local-development scenario the page only shows the stack trace in the following image (also check the console output).
I understand that it if someone provides a bad URL that can't be decoded this error will throw and therefore the page will not run. I've been looking for a while and haven't found nothing related to how to catch it on React (I'm not sure if that's really possible).
Any suggestions are welcome!

How to embed or get metdata from a link?

I am trying to make React Component where I like to display cards like which you see on Facebook or Linked In when you post some link.
You start with fetch() and parse the information from the return HTML, mainly in elements inside the <head>.
However, this is only going to work if the target site has super open CORS headers. Most sites don't, and for those cases you will need a server to do the fetching and perhaps parsing.

React - Links produce net::ERR_UNSAFE_REDIRECT in chrome

I have a react app that has several pages. When I refresh the page, I can successfully link to one other page. Subsequent links update the url address with the reference to the new page, but only load after the page refreshes.
Error messages in different browsers differ.
In chrome:
In firefox:
In safari:
I have seen this post which has very long, complicated suggestions about routing. I'm not sure if this is my problem yet, so have not yet explored the ideas set out as solutions.
2nd screenshot shows that something tries to load /your-path-to-fontawesome/css/all.css and most probably you don't have that file at that location (therefore receiving html instead). You need to config something somewhere in code, connected to fontawesome
Two separate issues here:
First, the combination ERR_BLOCKED_BY_CLIENT and ERR_UNSAFE_REDIRECT are usually the result of a browser extension, or the browser itself, blocking cross-site tracking. This would also make sense why you're only seeing it in a particular browser.
Second, the invalid MIME type for your CSS typically comes from one of two things. The most common, and easiest to fix, is that the path to that file is wrong. In this case, the server responds with a 404 page, giving you the invalid MIME type of text/html.
Another possibility is a library adding comments to the top of a CSS file that is meant to be minified before being sent to the client. Here's a more in-depth post about this issue. Would definitely double-check the file path, though, before digging deeper into this possibility. An easy way to check would just be to take that URL from the MIME type error and navigate to it in your browser to see what you get.

Custom 404 page in CakePHP 3.X

I want to create one custom 404 page for all errors coming to the website for production environment. For example if I receive missing controller or view error then it will redirect to
http://example.com/404.html, Also in some cases I will deliberately redirect it http://example.com/404.html
Earlier in CakePHP 2.x it was done by adding following action in AppContoller.php
public function appError($error) {
$this->redirect('/page-not-found.html',301,false);
}
But It is not working in CakePHP 3.x, I want to replicate same behavior in CakePHP 3.x
Do not redirect
The correct action to take if a page should render a 404 is to render a 404.
Redirecting to another page is confusing for users, especially since many browsers cache 301 responses making the original url inaccessible. This also affects e.g. search engines as the static file 404.html will have a 200 response code (unless you modify your webserver config) so it'll say 404 but simply not be.
The blog tutorial, which all devs should do before starting a project, guides you in the right direction:
public function view($id)
{
$article = $this->Articles->get($id);
$this->set(compact('article'));
}
The table method get returns a single entity object or throws an exception:
If the get operation does not find any results a Cake\Datasource\Exception\RecordNotFoundException will be raised. You can either catch this exception yourself, or allow CakePHP to convert it into a 404 error.
The controller code in this example doesn't need to have any "what if it doesn't exist" handling because by default if the record doesn't exist the result is a 404.
Changing the 404 template
If you want to change the way the 404 or 500 pages look change the template files
For all 4xx and 5xx errors the template files error400.ctp and error500.ctp are used respectively.
The error template is in your application, note that in production mode the output is very minimal.
If the get operation does not find any results a Cake\Datasource\Exception\RecordNotFoundException will be raised. You can either catch this exception yourself, or allow CakePHP to convert it into a 404 error.
The simplest way can be just implemented in two steps,
Step 1:
turn the debug mode off in config/app.php
Step 2:
Replace the content of src/Template/Layout/error.ctp with your custom layout.

Cakephp Custom Error pages

I am referring to the problem that has already been asked. CakePHP 2.0 - How to make custom error pages?
It gives me a lot idea of solving out the problem but instead of thowing exception I want to use it for all of my controller and actions. It suggested me to do where ever at particular location I want throw new NotFoundException(); I want it everywhere I mean where so ever controller or action is missing.
With debug turned off all your error are converted to either 400 or 500 errors. So you just need to customize your app/View/Errors/error400.ctp and app/View/Errors/error500.ctp as required.

Resources