exception

Exceptions must derive from BaseException

不羁的心 提交于 2020-06-28 03:41:35
问题 What am I missing here? import sys class MyBaseError(BaseException): def __init__(self, message, base_message=None, *args): self.message = message self.base_message = base_message super(MyBaseError, self).__init__() def __str__(self): if self.base_message is None: return self.message return self.message + " '" + str(self.base_message) + "'" class MyError(MyBaseError): """ """ class MyTypeError(MyError): """ """ def run_me(): raise MyTypeError("run_me") def sayonara(): try: run_me() except

Unable to start activity Resources$NotFoundException

北城以北 提交于 2020-06-25 09:19:07
问题 I've had an app published and running on google play for several months. Today I received an error from a user with a resource not found exception. I thought i may have forgotten some drawable. From the error i got the object ID (I took ID 0x7f030003 from the error) and looked for it in R.java to determine what object was missing. To my surprise I found that the IDis from my Main Activity, so I'm sure I've not forgotten this! My app starts with main and all other activities/fragments are

Processing unhandled exceptions in ASP.NET Core 3.1

自作多情 提交于 2020-06-24 14:58:05
问题 In ASP.NET Core 3.1 a feature was added where unhandled exceptions can be passed onto an instance of ILogger as noted here: Logging in .NET Core and ASP.NET Core I have a Server side Blazor website where I want to be able to process these exceptions in a function where I can log them to a database or perhaps send an email. However I am unable to come up with code to do this based on the provided documentation. Could someone provide sample code to trap unhandled exceptions? 回答1: I recommand to

Why can't I use a try block around my super() call?

a 夏天 提交于 2020-06-24 10:52:28
问题 So, in Java, the first line of your constructor HAS to be a call to super... be it implicitly calling super(), or explicitly calling another constructor. What I want to know is, why can't I put a try block around that? My specific case is that I have a mock class for a test. There is no default constructor, but I want one to make the tests simpler to read. I also want to wrap the exceptions thrown from the constructor into a RuntimeException. So, what I want to do is effectively this: public

Setting the message of a custom Exception without passing it to the base constructor

时间秒杀一切 提交于 2020-06-24 10:52:24
问题 I want to make a custom Exception in C#, but in theory I do need to do a little parsing first before I can make a human readable ExceptionMessage. The problem is that the orginal Message can only be set by calling the base constructor of Messsage , so I can't do any parsing in advance. I tried overring the Message property like this: public class CustomException : Exception { string _Message; public CustomException(dynamic json) : base("Plep") { // Some parsing to create a human readable

Setting the message of a custom Exception without passing it to the base constructor

♀尐吖头ヾ 提交于 2020-06-24 10:52:06
问题 I want to make a custom Exception in C#, but in theory I do need to do a little parsing first before I can make a human readable ExceptionMessage. The problem is that the orginal Message can only be set by calling the base constructor of Messsage , so I can't do any parsing in advance. I tried overring the Message property like this: public class CustomException : Exception { string _Message; public CustomException(dynamic json) : base("Plep") { // Some parsing to create a human readable

Maven Failsafe plugin - SurefireBooterForkException: There was an error in the forked process (TypeNotPresentExceptionProxy)

五迷三道 提交于 2020-06-24 08:24:46
问题 I get this strange stacktrace when running mvn clean verify -P P1 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-failsafe-plugin:2.21.0:verify (default) on project prj-name: There are test failures. [ERROR] [ERROR] Please refer to C:\path\to\project\target\failsafe-reports for the individual test results. [ERROR] Please refer to dump files (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream. [ERROR] org.apache.maven.surefire.booter

Maven Failsafe plugin - SurefireBooterForkException: There was an error in the forked process (TypeNotPresentExceptionProxy)

和自甴很熟 提交于 2020-06-24 08:24:33
问题 I get this strange stacktrace when running mvn clean verify -P P1 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-failsafe-plugin:2.21.0:verify (default) on project prj-name: There are test failures. [ERROR] [ERROR] Please refer to C:\path\to\project\target\failsafe-reports for the individual test results. [ERROR] Please refer to dump files (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream. [ERROR] org.apache.maven.surefire.booter

How to clear permgen memory space

爱⌒轻易说出口 提交于 2020-06-23 14:19:08
问题 I am using MAT to analyze memory. Size: 14.4 MB Classes: 7k Objects: 350.9k Class Loader: 116 I've got the above report using MAT memory analyzer. But I can't find any way to clear those classes, objects. Is there any way to remove all those object and clean permgen memory. Can we clean permgen memory or I have to increase xms, xmx and launcher.XXMaxPermSize size in eclipse.ini file and make sure all object are nullify after use. 回答1: As far as I know there is no function that clears permgen.

Is this a bug in JSON.NET or Entity Framework or am I doing something wrong while trying to serialize a list of Exceptions with JSON.NET?

大城市里の小女人 提交于 2020-06-23 08:31:47
问题 Got this error when trying to serialize a set of errors: "ISerializable type 'System.Data.Entity.Infrastructure.DbUpdateConcurrencyException' does not have a valid constructor. To correctly implement ISerializable a constructor that takes SerializationInfo and StreamingContext parameters should be present." The constructor is in fact present in the base classes, but it is a protected member. Someone asked to see the JSON: { "$type": "System.Data.Entity.Infrastructure