I tried to add a route for the error 404:
Route::get('404', function()
{
echo "404";
return "404";
});
but I have this error with "laravel/framework": "5.3.*":
Trying to get property of non-object
How can I display an error message or render a view ?
You don't need to create any route for 404 error.
Just create a view at
resources/views/errors/404.blade.php
And in that view, write the message you want to show on 404 error
Related
I am using interceptor for checking responses, and if there is error I am rejecting the response, which is working fine, but issue is after rejecting response I am getting html file which is not rendering properly, even in html response (from browser console), it is showing html tags but it is not rendering that and displaying blank page.
Any help would be highly appreciated.
I am using route provider for switching, where I am hitting to json and getting response.
$routeProvider
.when("/news", {
templateUrl: "newsView.html",
controller: "newsController",
resolve: {
message: $http.post('xyz.json',{});
}
}
})
Now my json contains error message, like below:
{data:{errorCode:'231',message:'Custom Error'}}
After this I have created one interceptor which check if there is error message then it rejects the response else it returns the response.
if(data.errorCode)
{
add error code to the custom directive message list
$q.reject(response)
}
return response
In my html file I have a custom directive.
<div message></div>
Now issue is that I am getting json file with error code and it is getting required data, and after that I am getting html file news.html file which is not rendering the custom directive and if I remove the reject , it is showing custom directive
I used adal-angular js to protect my routes.
$routeProvider.
when("/dashboard", { templateUrl: "Views/Dashboard.html", controller: "DashboardController", requireADLogin: true })
But when Adal getting token, I have an error in console:
Error: [$compile:tpload] Failed to load template: Views/Dashboard.html (HTTP status: undefined undefined)
Could someone know why it happens?
First, forgive my english.
For me only have worked when I specified "/myUrl" in anonymousEndpoints. That skip the interceptor for this backend url.
I had an issue with this for angular ui bootstrap templates. Adding the path "uib/" to the anonymous endpoints array fixed my problem.
I'm trying to redirect a user to a login page if they are not currently logged in:
var user = Session.checkSession();
if(user){
$scope.session.user = user;
} else {
// redirect to login page
$state.go('access.signin');
}
$state is injected into this controller correctly, because if I put dummy.state instead of access.signin I get the error:
Error: Could not resolve 'dummy.state' from state ''
$state.go('access.signin') is used successfully elsewhere in the app, so doesn't look like there's anything wrong with the route. What am I doing wrong here?
I have written a simple Angular-js app as below:
angular.module("myApp",['ngRoute'])
.config(['$routeProvider',function($routeProvider){
$routeProvider
.when('/',{
name:'route1',
controller:'Route1Ctrl',
template:'partials/route1.tpl.html'
})
.otherwise({redirectTo:'/'});
}])
.controller('Route1Ctrl',['$scope',function($scope){
}});
The app fails to load and the only error message that I can see in the chrome console box is:
Uncaught objet
What can I do to get more usable error messages ?
instead of template: you must use templateUrl
I'm missing something in my understanding or code here...
I've got a very basic CRUD app to list/add/edit/delete categories, and it works fine when I define the primary key on the table as "id", but when I rename the database column to "categoryId", the PUT url does not include the key value, and I end up for a 404 error for an unhandled path...
stack:
IIS 7.5 w/ Slim PHP for RESTful services
// Route excerpt
...
when('/categories', {templateUrl: 'partials/categoryList.html', controller: CategoryListCtrl}).
when('/categories/new', {templateUrl: 'partials/categoryDetail.html', controller: CategoryNewCtrl}).
when('/categories/:id', {templateUrl: 'partials/categoryDetail.html', controller: CategoryEditCtrl}).
...
angular.module('myServices', ['ngResource'])
.factory('Category', function($resource){
return $resource('../api/index.php/categories/:id', {id:'#categoryId'},
{ update: {method:'PUT' } }
);
})
// WORKS when attribute is 'id'
.factory('Category', function($resource){
return $resource('../api/index.php/categories/:id', {id:'#id'},
{ update: {method:'PUT' } }
);
})
// FAILS with 404 when attribute is 'categoryId'
.factory('Category', function($resource){
return $resource('../api/index.php/categories/:id', {id:'#categoryId'},
{ update: {method:'PUT' } }
);
})
Of course there are a number of other places in the code where the name is changed, but the effect I'm seeing seems to be related to the ngResource.
The first method produces an URL that works...
categories/1?description=null&name=Observation&report=null
/api/index.php
The second produces this...
categories?categoryId=1&description=null&name=Observation&report=null
/api/index.php
with the 404 error due to the malformed path.
Is there another parameter (or directive or something) required to get the renamed attribute to be used in the URL?
I tested the put with the second resource and it works as expected. The only way I could reproduce that was if I was issuing a GET instead of a PUT. If you open this demo and view the network tab (chrome/etc) you can see what the put and what the get produce.
http://plnkr.co/edit/tI9KpqDp49pXuJJVjivm?p=preview
The GET produces the querystring parameterized data:
GET produces:
Request URL:http://run.plnkr.co/api/index.php/categories?categoryId=123
Request Method:GET
PUT produces:
Request URL:http://run.plnkr.co/api/index.php/categories/123
Request Method:PUT
Code:
var test= $resource('../api/index.php/categories/:id', {id:'#categoryId'},
{ update: {method:'PUT' } }
);
var test2= $resource('../api/index.php/categories/:id', {id:'#categoryId'},
{ get: {method:'GET' } }
);
test.update({categoryId:123});
test2.get({categoryId:123});