How to customize error pages Symfony? - exception

I followed the instructions on the page https://symfony.com/doc/current/controller/error_pages.html#overriding-the-default-error-templates and have created my own errors templates to display error pages depending on status code of the error (i.e. error.html.twig contains {{status_code}} variable):
|-- app/
|-- Resources/
|-- TwigBundle/
|-- views/
|-- Exception/
|-- error.html.twig
|-- exception.html.twig
But:
pages error.html.twig and exception.html.twig never shown, no matter what env is set.
in the production environment I can see fatal errors and every kind of Symfony Exceptions which it should never take place - yet it is prod env! (edit: The problem only occurs on my local machine - on remote server I see just default browser's error pages)
How to fix this? I found only 1 similar topic at stack (How to Customize Error Pages Template In symfony 3.1?) but it doesn't contain the right answer.

Related

AWS Amplify: DevTools failed to load SourceMap: Unexpected token < in JSON at position 0

I am getting several warnings when loading my website on Google Chrome similar to the following:
DevTools failed to load SourceMap: Could not parse content for https://mywebsite.com/static/js/2.abcd1234.chunk.js.map: Unexpected token < in JSON at position 0
My webapp is a React application (create-react-app) deployed on AWS Amplify. I do not get these warnings when running the app locally. How do I get rid of these warnings?
This is a problem caused by using react-router with AWS amplify. See this github issue. It suggests adding the following entry in the Rewrites and redirects section of App settings in AWS Amplify:
Source address:
</^[^.]+$|\.(?!(css|gif|ico|jpg|js|png|txt|svg|woff|ttf)$)([^.]+$)/>
Target address:
/index.html
Type:
200 (Rewrite)
To solve my problem, I added the map extension to this regex:
Source address:
</^[^.]+$|\.(?!(css|gif|ico|jpg|js|png|txt|svg|woff|ttf|map)$)([^.]+$)/>
I checked my Rewrites and redirects settings and it was already configured as per the below answer by "roob" but also had json at the end. I removed it to see if that helped. Either way, I still got the error.
More research with a colleague and found another root cause. Answered here:
AWS Amplify error: Failed to parse source map... file: Error: ENOENT: no such file or directory

Jekyll and Strapi: The Strapi server sent a error with the following status: 404. Please make sure it is correctly running

I am currently trying to follow this tutorial (https://blog.strapi.io/building-a-static-website-using-jekyll-and-strapi/) and everything was working fine until the "Posts List" step. Once I added the _layouts/home.html file, changed _config.yml and restarted the jekyll server (bundle exec jekyll serve), I ended up with an error message:
jekyll 3.8.5 | Error: The Strapi server sent a error with the following status: 404. Please make sure it is correctly running.
Thing is, the strapi server IS RUNNING... I have access to the the strapi admin backend and I can access and view the Posts json object by visiting: http://localhost:1337/posts.
Please make sure you have data in your Post content type.
Create some posts and then retry.

YAML unmarshal error cannot unmarshal !!str ` ` to str

I am trying to push my Spring Boot application on Pivotal Cloud Foundry (PCF) via manifest.yml file.
While pushing the app i am getting the following error:
{
Pushing from manifest to org mastercard_connect / space developer-sandbox as e069875...
Using manifest file C:\Sayli\Workspace\PCF\healthwatch-api\healthwatch-api\manifest.yml
yaml: unmarshal errors:
line 6: cannot unmarshal !!str `healthw...` into []string
FAILED }
Here is the manifest.yml file:
{applications:
- name: health-watch-api
memory: 2GB
instances: 1
paths: healthwatch-api-jar\target\healthwatch-api-jar-0.0.1-SNAPSHOT.jar
services: healthwatch-api-database
}
Your manifest is not valid. The link #K.AJ posted is a good reference.
https://docs.cloudfoundry.org/devguide/deploy-apps/manifest.html
Here's an example, which uses the values from your file.
---
applications:
- name: health-watch-api
memory: 2G
path: healthwatch-api-jar/target/healthwatch-api-jar-0.0.1-SNAPSHOT.jar
services:
- healthwatch-api-database
You don't need the leading/trailing { }'s, it's path not paths and services is an array. I think the last one is what the cli is complaining about the most.
Hope that helps!
I got this error while using Pulumi, using GitHub Actions. The cause was not having a Variable available in the GH yaml config. This resulted in the value that I was trying to add to pulumi.dev.yaml being added as 'null'; after correcting this issue, I could see the correct value.

Polymer 2 iron-ajax is loading the wrong local file

When loading a local json file with the iron-ajax Polymer web component the response returned is the contents of index.html, not the json file.
<iron-ajax auto url="data.json" on-response="handleResponse" handle-as="json"></iron-ajax>
I am checking the response in Chrome developer tools under "Network" and the response given is the same as the index.html file. I am using Polymer 2.0 starter kit as a front end with Flask on the back end. Apologies if this is a simple mistake but I am new to JavaScript.
My simplified file structure looks like:
/app
|-- app.py
|-- /static
|-- index.html
|-- /bower_components
|-- /src
|-- data.json *(file to be loaded)*
|-- my-app.html
|-- my-view.html *(view to load file)*
EDIT:
I believe the problem may be to do with this catch-all in the app.py file from the boiler plate I am using. I realise I do not understand how the relative url's are working in this application.
#app.route("/static/<path:path>")
def static_c(path):
return current_app.send_static_file(path)
#app.route('/', defaults={'path': ''})
#app.route('/<path:path>')
def catch_all(path):
return current_app.send_static_file("index.html")

Heroku - Can't access or create database JSON data of ruby app, error HTTP 500

I'm having a problem in Production when accessing the JSON (let's call it mydata.json) where I store the data of my ruby webapp, deployed with Heroku. The way I access the download of this file is by putting into the browser:
my-heroku-page.herokuapp.com/mydata.json
but I get the HTTP 500 error page.
Always using the browser, when I try to create it I get the Ruby page:
We're sorry, but something went wrong.
If you are the application owner check the logs for more information.
First I must say I'm using the same source code I used for another webapp that is actually working, I just modified the database.yml according to my new host, database, username and password. The previous webapp was perfectly working, i.e I could create the table and access the data. Secondly the error doesn't occur with localhost.
I tried to create a Dataclip in Heroku:
Select * from mydata order by created_at desc;
but I get the error:
"Your query couldn't be created."
ERROR: relation "mydata" does not exist
LINE 3: FROM mydata
Plus when I check the heroku pg:info I get 0 Tables
=== DATABASE_URL
Plan: Hobby-dev
Status: Available
Connections: 0/20
PG Version: 9.5.5
Created: 2016-11-15 08:30 UTC
Data Size: 7.4 MB
Tables: 0
Rows: 0/10000 (In compliance)
Fork/Follow: Unsupported
Rollback: Unsupported
Add-on: postgresql-convex-54172
It seems like mydata.json is not created in production, but in localhost is working fine and I can create/download a blank one. I'm sure I'm missing something easy here, maybe in the database.yml.
I will edit the question if additional info are required. Any help is appreciated.
Thanks,
Simone