草庐IT

something_bad_happened_exception

全部标签

php - Zend 框架 : How to handle exceptions in Ajax requests?

通常当抛出异常时,错误Controller接受命令并显示带有常规通用页眉和页脚的错误页面。Ajax请求中不需要这种行为。因为如果出现错误,整个html页面都会被发送过来。在我直接在div中加载http响应内容的情况下,这更不受欢迎。在Ajax请求的情况下,我只想接收异常抛出的“实际错误”。我该怎么做?我认为,一种肮脏的方法可能是:在ajax请求中设置一个var并进行相应的处理。不是一个好的解决方案。 最佳答案 如果您使用contextSwitch或ajaxContext操作助手来编码您的错误(可能关闭autoJsonSerializ

java - 为什么 "activator start"会因 "Bad application path"而失败?

我使用activatornew在PlayFramework中创建了一个应用程序。在activator启动时,此应用程序出现以下错误:Badapplicationpath:-Dhttp.port=9000如何解决问题? 最佳答案 我遇到了同样的问题,但只有在我尝试使用Bat文件运行Play应用程序并添加一些配置参数时,才使用来自激活器的dist命令创建二进制分发后,我遇到了同样的错误。这是我得到的错误Badapplicationpath:-Dhttp.port=9009所以我解决的方法是通过编辑Bat文件。我手动将所有配置参数添加到A

java - 调用 Exception.printStackTrace 时出现 AbstractMethodError

在catch子句中,我想打印异常的跟踪:try{...}catch(Exceptionexc){exc.printStackTrace();...}但在某些情况下,我没有得到堆栈跟踪,而是看到类似这样的内容:Exceptioninthread"pool-1-thread-2"java.lang.AbstractMethodError:java.lang.Exception.printStackTrace()V...通常,如果库在运行时的版本与编译时的版本不同,就会发生此异常,但在这种情况下,我使用的是Java库中的类。printStackTrace是在Throwable中实现的,所以这

java - 谷歌应用引擎 - org.datanucleus.exceptions.NucleusUserException : Object Manager has been closed

为什么下面的代码会导致org.datanucleus.exceptions.NucleusUserException:对象管理器已关闭?异常似乎是在query.getResultList()处抛出的。publicfinalvoidremoveUserTokens(finalStringusername){finalQueryquery=entityManager.createQuery("SELECTpFROMPersistentLoginpWHEREusername=:username");query.setParameter("username",username);for(Obj

exception - 为什么我的 elasticsearch 无法在 JAVA API 中构建 transportclient?

我在Java中有一个简单的elasticsearch代码是这样的:publicclassTryElastic{publicstaticvoidmain(String[]args)throwsUnknownHostException{Mapjson=newHashMap();json.put("user","kimchy");json.put("postDate",newDate());json.put("message","tryingoutElasticsearch");try{Settingssettings=Settings.settingsBuilder().put("clus

Java 泛型方法返回不同的类型 - 无一异常(exception)

我发现了一些奇怪的代码,其中我说“这永远不会被调用,因为它会抛出类转换异常”。好吧,代码被调用并正常工作。谁能给我解释一下:为什么会这样?方法getZipList()被定义为返回一个字符串列表,但内部逻辑返回一个包含不同对象的列表。同样在main方法内部,字符串列表应为“列表”,但列表包含不同的内容。publicclassGenericMethodList{publicstaticvoidmain(String[]args){GenericMethodListo=newGenericMethodList();Listlist=o.getZipList(true);Iteratorite

java - Spring 启动: No matching bean found exception

我的第一个SpringBoot应用程序中的登录页面:主类@SpringBootApplicationpublicclassMainGateextendsSpringBootServletInitializer{@OverrideprotectedSpringApplicationBuilderconfigure(SpringApplicationBuilderapplication){returnapplication.sources(MainGate.class);}publicstaticvoidmain(String...args){System.out.println("Boo

java - 没有 happens-before 的安全发布?除了 final 还有什么?

根据JCP(16.2.2.安全发布):Thishappens-beforeguaranteeisactuallyastrongerpromiseofvisibilityandorderingthanmadebysafepublication.WhenXissafelypublishedfromAtoB,thesafepublicationguaranteesvisibilityofthestateofX,butnotofthestateofothervariablesAmayhavetouched.ButifAputtingXonaqueuehappens-beforeBfetches

Java SWT : Wrap main loop in exception handler?

您可能知道,标准的SWT主循环如下所示:Displaydisplay=newDisplay();Shellshell=newShell(display);...shell.open();while(!shell.isDisposed()){if(!display.readAndDispatch()){display.sleep();}}display.dispose();最近,我与一位同事争论将主循环包装在try-catch中是否有意义,如下所示:Displaydisplay=newDisplay();Shellshell=newShell(display);...shell.open

JAVA + try catch(FileNotFoundException e) 进入 catch(Exception e)?

我有一些命令可以在磁盘上创建一个文件。因为必须在其中创建文件的文件夹是动态的,所以我有一个问题(FileNotFoundExceptione)。在同一个tryblock中,我已经有了一个catch(Exceptione)block。出于某种原因,当我运行我的代码并且该文件夹尚不存在时,将使用catch(Exceptione)block,而不是FileNotFoundExceptionblock。虽然调试器很清楚(至少对我而言),但显示了FileNotFoundException:java.io.FileNotFoundException:c:\mydata\2F8890C2-13B9-