throw

    1熱度

    2回答

    我必須爲我的單元測試導致bad_alloc(基本上,對於100%的代碼覆蓋率,我無法更改某些函數)。我該怎麼辦? 這是我的代碼示例。我必須在這裏導致bad_alloc。 bool insert(const Value& v) { Value * new_value; try { new_value = new Value; } catch (st

    2熱度

    2回答

    如果我想要拯救一個潛在的錯誤並抓住潛在的投擲物,我應該如何套住它們?這兩者是否相同,這只是一個偏好問題? begin catch(:some_throw) do ... end rescue SomeError ... end catch(:some_throw) do begin ... rescue SomeErr

    0熱度

    1回答

    在編寫複雜邏輯檢查時,我無法理解C++中的運算符分組。 基本上,我只是擔心,如果這個代碼: int getIndex(int i) throw(Exception) { return (i >= 0 && i < length) ? array[i] : throw IndexOutOfBoundsException(); } 是相同的,因爲這一個: int getIndex(in

    1熱度

    1回答

    我有一個關於測試用戶定義頭文件的問題。 所以,這裏是例子。 #include <iostream> using namesapce std; #include "header.h" #include "header.h" // I wonder the reason why I need to write this down two time for testing ifndef test

    0熱度

    1回答

    我在我的應用程序中使用下面的代碼來創建日曆。當我更新Xcode和移動到Swift 2.0時,此行let calendarWasSaved = eventStore.saveCalendar(newCalendar, commit: true, error: &error)上出現錯誤。 // Save the calendar using the Event Store instance

    0熱度

    1回答

    我有一些這樣的代碼的打擊, 如果擲1,顯示將 catch in main throw 1 如果擲2,顯示將 catch in test throw 2 但如果我想要這樣的顯示, catch in test throw 2 catch in main throw 2 我該怎麼辦? function test(database) { if(1) throw 'thro

    0熱度

    2回答

    有沒有更好的解決方案將Swift錯誤從一個函數轉發到另一個函數? 在那一刻,我在做這樣的: enum Error:ErrorType{ case Error1 case Error2 } func func1()throws{ do{ try func2() }catch Error.Error1{ throw Erro

    -1熱度

    1回答

    我與SQL Server 2008 R2的工作,我有一個存儲過程,在那裏我試圖拋出errror throw 50001, 'Couldnot process,Please verify Transaction ID and EmbossLine', 1 但查詢沒有得到執行,並拋出錯誤50001.它在SQL Server 2012上工作正常。我認爲版本存在一些問題。有沒有其他方法可以在SQL S

    1熱度

    1回答

    捕獲異常以確定它是否使用非默認消息構造時是否有方法。 try { throw new Exception(message); // case 1 //throw new Exception(); // case 2 } catch(Exception exp) { /* what do I put

    23熱度

    6回答

    在哪些情況下,以下兩個代碼不相同? { // some code, may throw and/or have side effects } try { // same code as above } catch(...) { throw; } 編輯只是爲了澄清,我不感興趣(i)中偏離上述模式(如在catch塊更多的代碼),也沒有(II)旨在邀請約光顧的