exception

DbContext.SaveChangesAsync Exception Handling

不羁岁月 提交于 2021-02-10 07:26:03
问题 When scaffolding a new ApiController with asynchronous actions and Entity Framework support in Visual Studio 2013, some methods wrap DbContext.SaveChangesAsync calls in try-catch blocks. For instance, the Put method, try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmployeeExists(id)) { return NotFound(); } throw; } From msdn.microsoft.com about DbUpdateConcurrencyException , Exception thrown by DbContext when it was expected that SaveChanges for an entity

DbContext.SaveChangesAsync Exception Handling

若如初见. 提交于 2021-02-10 07:23:10
问题 When scaffolding a new ApiController with asynchronous actions and Entity Framework support in Visual Studio 2013, some methods wrap DbContext.SaveChangesAsync calls in try-catch blocks. For instance, the Put method, try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmployeeExists(id)) { return NotFound(); } throw; } From msdn.microsoft.com about DbUpdateConcurrencyException , Exception thrown by DbContext when it was expected that SaveChanges for an entity

java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/validation/Validation

北慕城南 提交于 2021-02-10 05:15:28
问题 Using maven to add activemq, there is a problem about conflicting jar when I unit-test in IDE, the exception message is: java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/validation/Validation i have excluded the validation from javaee, as following: <dependency> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <version>6.0</version> <scope>provided</scope> <exclusions> <exclusion> <groupId>javax.validation</groupId>

Create CFrameWnd gives first-chance exceptions--why?

两盒软妹~` 提交于 2021-02-09 11:31:44
问题 I'm attempting to write a simple MFC app that draws in a scrollable window, using code based on CFrameWnd. The code below is adapted from Prosise "Programming Windows with MFC", 2nd ed, pp 89ff. When I run this in the debugger, I get two first-chance exceptions. If I ignore these, the window appears as expected, and I can draw in it. If I enable break on "C++ exceptions", I get a stack which is only "internal" code, for which I do not have the source. By stepping through the code, I find that

TextInputLayout error: Couldn't resolve resource @string/path_password_strike_through

主宰稳场 提交于 2021-02-08 21:33:13
问题 AndroidX: I'm trying to use a TextInputLayout but when I put it in my XML I receive this error: Render Problem: Couldn't resolve resource @string/path_password_strike_through Failed to initiate one or more classes The following classes could not be instantiated: com.google.android.material.textfield.TextInputLayout Here the Stack Trace: java.lang.AssertionError: error in parsing "g/"java.lang.NumberFormatException: For input string: "/" at android.util.PathParser_Delegate.getFloats(PathParser

TextInputLayout error: Couldn't resolve resource @string/path_password_strike_through

我的未来我决定 提交于 2021-02-08 21:32:10
问题 AndroidX: I'm trying to use a TextInputLayout but when I put it in my XML I receive this error: Render Problem: Couldn't resolve resource @string/path_password_strike_through Failed to initiate one or more classes The following classes could not be instantiated: com.google.android.material.textfield.TextInputLayout Here the Stack Trace: java.lang.AssertionError: error in parsing "g/"java.lang.NumberFormatException: For input string: "/" at android.util.PathParser_Delegate.getFloats(PathParser

Received “UnboundLocalError: local variable 'e' referenced before assignment” when the variable was initialized

早过忘川 提交于 2021-02-08 20:52:50
问题 [Community edit to give reproducible example:] def main(): e = None print(locals()) while not e: try: raise Exception except Exception as e: pass main() produces ~/coding$ python3.3 quiz2.py {'e': None} Traceback (most recent call last): File "quiz2.py", line 11, in <module> main() File "quiz2.py", line 5, in main while not e: UnboundLocalError: local variable 'e' referenced before assignment [EDITED] to include a reproducible code I am trying to run a while-loop, and the condition I use is

Exception class - what() function

喜欢而已 提交于 2021-02-08 19:42:36
问题 I'm currently working on my own exception class that inherits from std::exception , and I'm not sure if I should make my own what() or just call std::exception("message") in my class constructor. This is my current code: FilterException::FilterException(const char* message, int num) noexcept : error_message(message), error_number(num) {} const char* FilterException::what() const noexcept { return error_message.c_str(); } FilterException::~FilterException() noexcept { } int FilterException:

Exception class - what() function

一世执手 提交于 2021-02-08 19:41:56
问题 I'm currently working on my own exception class that inherits from std::exception , and I'm not sure if I should make my own what() or just call std::exception("message") in my class constructor. This is my current code: FilterException::FilterException(const char* message, int num) noexcept : error_message(message), error_number(num) {} const char* FilterException::what() const noexcept { return error_message.c_str(); } FilterException::~FilterException() noexcept { } int FilterException:

What if an object passed into std::swap throws an exception during swapping?

◇◆丶佛笑我妖孽 提交于 2021-02-08 14:16:04
问题 The C++ standard guarantees that std::swap will throw no exception. However, what if an object to swap throws an exception during swapping? Next, how should the caller find an exception has happened? and what measures should the caller take? PS: It is very common that a constructor throws an exception. struct A { A(const A&) { throw 1; } A& operator =(const A&) { throw 2; return *this; } }; int main() { A a1, a2; std::swap(a1, a2); // An exception happened, but the caller doesn't know. // How