标签: custom-errors

Java:自定义异常错误

$ javac TestExceptions.java 
TestExceptions.java:11: cannot find symbol
symbol  : class test
location: class TestExceptions
            throw new TestExceptions.test("If you see me, exceptions work!");
                                    ^
1 error
Run Code Online (Sandbox Code Playgroud)

import java.util.*;
import java.io.*;

public class TestExceptions {
    static void test(String message) throws java.lang.Error{
        System.out.println(message);
    }   

    public static void main(String[] args){
        try {
             // Why does it not access TestExceptions.test-method in the class?
            throw new TestExceptions.test("If you see me, exceptions work!");
        }catch(java.lang.Error a){
            System.out.println("Working Status: " + a.getMessage() );
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

java error-handling custom-errors

2
推荐指数
1
解决办法
1万
查看次数

在ASP.Net URL中禁用aspxerrorpath参数

我已将以下内容添加到我的web.config中,以将用户重定向到自定义错误页面而不是默认页面

'/'应用程序中的服务器错误.

错误信息.

用户被重定向到 error.html?aspxerrorpath=/paymentservices.svc

有没有办法删除该?aspxerrorpath=/paymentservices.svc部分?

web.config中:

<system.web>
    <customErrors defaultRedirect="~/ErrorPages/error.html"
  mode="On" xdt:Transform="Replace">
    <error statusCode="500" redirect="~/ErrorPages/error.html"/>
    <error statusCode="404" redirect="~/ErrorPages/error.html"/>
    </customErrors>
</system.web>
Run Code Online (Sandbox Code Playgroud)

asp.net web-config custom-error-pages custom-errors

2
推荐指数
1
解决办法
3055
查看次数

如何从 Fastify v3 返回自定义错误?

如你所知,Fastify 中的默认错误界面如下所示

{
    "statusCode": 400,
    "error": "Bad Request",
    "message": "Missing property blah-blah"
}
Run Code Online (Sandbox Code Playgroud)

我真的希望能够扔掉类似的东西

{
    "statusCode": 400,
    "error": "Bad Request",
    "message": "Missing property blah-blah",
    "myCustomError": "yo yo I am custom"
}
Run Code Online (Sandbox Code Playgroud)

setErrorHandler我尝试了使用和 的多种(真的很多!)组合,addHook("onError")但我无法返回任何自定义错误。无论我做什么,我从处理程序内部抛出的自定义错误都会以某种方式转换为这个默认接口,并且无法找到解决方法。我也尝试过使用onSendonResponse钩子。我尝试过的一切都没有成功。:(

Fastify v3 中是否有可能返回自定义错误?如果在 v3 中无法实现,那么 Fastify v4 又如何呢?有人能提供一个在 Fastify 中启用自定义错误的代码设计吗?

custom-errors custom-error-handling fastify

2
推荐指数
1
解决办法
3184
查看次数

Spring MVC自定义错误和国际化

在我的Web应用程序中,我使用注释处理错误.一切正常,我可以通过"message"参数使用自定义消息.

@Digits(fraction = 0, integer = 3, message="my custom error message...")
private String price;
Run Code Online (Sandbox Code Playgroud)

现在,我正在尝试使用.properties文件将此消息国际化,但我肯定会错过一些内容而无法使其工作.

我的春天配置:

<beans:bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
    <beans:property name="basenames" value="classpath:i18n/messages, classpath:i18n/errors" />
    <beans:property name="defaultEncoding" value="UTF-8" />
</beans:bean>

<beans:bean name="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
    <beans:property name="validationMessageSource">
        <beans:ref bean="messageSource" />
    </beans:property>
</beans:bean>

<beans:bean id="localeResolver" class="org.springframework.web.servlet.i18n.FixedLocaleResolver">
    <beans:property name="defaultLocale" value="fr" />
</beans:bean>
Run Code Online (Sandbox Code Playgroud)

我的新豆子:

@Digits(fraction = 0, integer = 3)
private String price;
Run Code Online (Sandbox Code Playgroud)

我的"errors_fr.properties"文件.我已经尝试了一切:

Digits.myBean.myNestedBean.price = my custom error message...
Digits.myNestedBean.price = my custom error message...
javax.validation.constraints.Digits.myNestedBean.price = my custom error message...
Run Code Online (Sandbox Code Playgroud)

我总是从spring获得相同的通用消息,就像spring没有检测到我的.properties文件一样.顺便说一下,调试时可以在BindingResult对象中找到上面的消息键.

我在这里错过了什么?

请注意,我已经在我的jsp(在"messages_fr.properties"文件中)中有国际化的消息,它们工作正常.

validation spring-mvc internationalization custom-errors

1
推荐指数
1
解决办法
1万
查看次数

WINAPI SetLastError与C++ Keword投掷

WINAPI SetLastError()和C++关键字有throw什么区别?例如,是SetLastError(5);throw 5;是一样的?

c++ winapi exception custom-errors

0
推荐指数
1
解决办法
921
查看次数