Questions tagged [custom-error-handling]
195 questions
125
votes
19 answers
Null check chain vs catching NullPointerException
A web service returns a huge XML and I need to access deeply nested fields of it. For example:
return wsObject.getFoo().getBar().getBaz().getInt()
The problem is that getFoo(), getBar(), getBaz() may all return null.
However, if I check for null in…

David Frank
- 5,918
- 8
- 28
- 43
27
votes
3 answers
Is it possible to use a Relative path when setting a custom error page in IIS7?
I'm trying to set a custom 404 error page for my web application. The trouble is that this application will be deployed to a number of different environments. Sometimes it will be in a virtual directory and sometimes it won't.
I have the error page…

Martin Brown
- 24,692
- 14
- 77
- 122
11
votes
1 answer
Add extra properties in Custom Exception to return to AJAX function
I have a custom exception class as follows:
Public Class SamException
Inherits Exception
Public Sub New()
' Add other code for custom properties here.
End Sub
Public Property OfferBugSend As Boolean = True
…

Jamie Hartnoll
- 7,231
- 13
- 58
- 97
10
votes
6 answers
How to avoid “memory … exhausted” error when using debug_backtrace() in custom error handler?
I wrote an error handler for my website that looks like this:
function errorHandler($number, $string, $file, $line, $context, $type = '') {
// save stuff in DB
}
Which I register like this:
set_error_handler('errorHandler', E_ALL);
I save all of…

Nate
- 26,164
- 34
- 130
- 214
10
votes
1 answer
nginx error location for all servers
Is it possible to define a common location for all servers? From nginx location documentation I've seen that location depends on server. I would like to do something like this:
...
http {
error_page 404 /error/404.html;
…

Miquel
- 8,339
- 11
- 59
- 82
10
votes
1 answer
Nginx, PHP + FPM Custom Error Pages
I am trying to create some custom error pages but can't seem to get the 500 one working.
I have the following config:
server {
listen 80;
root /var/www/devsite;
index index.php;
server_name devsite;
error_page 403 =…

Ken
- 499
- 6
- 18
9
votes
3 answers
Can ESLint help you prevent Unhandled-Promise-Rejections?
Does eslint have any ability to warn about places to prevent Unhandled-Promise-Rejections?
Unhandled promise rejections are deprecated. In the future, promise
rejections that are not handled will terminate the Node.js process
with a non-zero exit…

Lonnie Best
- 9,936
- 10
- 57
- 97
7
votes
1 answer
Is there a way to change HttpWebRequest behavior on 400/500 status codes?
I am working on building a fluent REST client interface on top of the HttpWebRequest/HttpWebResponse types in .NET. So far, so good...however I am trying to develop a pluggable security framework that can automatically handle security token…

jrista
- 32,447
- 15
- 90
- 130
7
votes
2 answers
Customized error responses for ApiVersioning errors in webapi dotnet core
I am creating a package lib for all the errors in a Webapi service. This library will be used for providing custom responses for BadRequest, BadArgument, ApiVersionsing etc.. related errors. I need help in customizing Apiversion related errors for -…

arpymastro
- 751
- 3
- 16
- 34
6
votes
2 answers
Why custom Rest Error Handler is not getting called when rest template throw exception?
I am trying to cover all of the rest template calls in my class for exception handling. Using Custom exception handling with error handler in spring boot application.
For this i have created a rest template bean in config and set error handler in it…

Pooja Jain
- 61
- 5
6
votes
1 answer
Custom error message for Postgresql CHECK IN list constraint
I would like to create a more specific error message for Postgres CHECK IN violations. So for example a violation of the following CHECK constraint on a column:
management_zone varchar(15) NOT NULL CHECK (management_zone IN ('Marine', 'Terrestrial')…

Ric
- 75
- 1
- 8
6
votes
2 answers
Handling error codes from multiple libraries in C
Very often, I have to use multiple libraries that handle errors differently or define their own enums for errors. This makes it difficult to write functions that might have to deal with errors from different sources, and then return its own error…

James Hagborg
- 135
- 6
6
votes
1 answer
WCF Routing Service - Dynamic Error Handling
I'm learning about what can be done with the WCF Routing Service. Still at the 'screwing around with it to see what it can do' phase.
My understanding of the Routing Service is that when a message comes through, the service will try to pass it on to…

Daniel Schealler
- 390
- 1
- 16
5
votes
3 answers
What numbers should be used with vbObjectError?
This page says:
"If you are generating errors, then you should add your number to the
vbObjectError constant. Eg Err.Raise Number = vbObjectError + 1000.
The range 513 - 65535 is available for user defined errors."
also O'Reilly says:
"we are…

johny why
- 2,047
- 7
- 27
- 52
5
votes
1 answer
How to set a custom ErrorRenderer in symfony 5?
Problem:
I tried to register a CustomErrorRenderer on Symfony 5 to render my CustomException, but all the time the TwigErrorRenderer is called. I thought probably self-defined renderers might be preferred?
CustomErrorRenderer.php:
namespace…

myself
- 63
- 5