exception-handling

How should I handle Exception in this scenario

冷暖自知 提交于 2019-12-25 06:29:29
问题 Hi there I am learning OOP by writing a dummy Library management project in Java. In serachBook(), if book is found in ArrayList, it returns book object, if not found it throws custom exception BookNotFound. Question 1: Should it just return null and check the returned value at calling code for null or throw custom exception BookNotFound. Currently I believe BookNotFound is appropriate and am currently doing it. However I am finding one more difficulty: In addbook(), I first call searchBook()

How to handle this Data Abort exception in ARM 7? mode in CPSR 0x17 and board stucked at 0x10

时光怂恿深爱的人放手 提交于 2019-12-25 06:27:59
问题 I am working on ARM 7 board and facing data handler related issues i.e. many times board got stuck at 0x10 . I checked CPSR register and found mode is 0x17(Abort mode). How to handle this Data Abort exception in ARM 7 ? I tried to configure in exception vector but it failed. Also the R14(Linked Register) is different at every time. Disassembly Next label is a Thumb label FIQ_MODE: USER_MODE: --> 00000010 E59FF018 LDR PC, [PC, #+24] ;D ABT [0x30] = USR_MODE (0x10) Using IAR. Data Abort

Alternative to Throwing Param Exceptions in PowerShell?

五迷三道 提交于 2019-12-25 05:17:27
问题 Bottom Line Up Front I'm looking for a method to validate powershell (v1) command line parameters without propagating exceptions back to the command line. Details I have a powershell script that currently uses param in conjunction with [ValidateNotNullOrEmpty] to validate command line paramaters: param( [string] [ValidateNotNullOrEmpty()]$domain = $(throw "Domain (-d) param required.") ) We're changing the paradigm of error handling where we no longer want to pass exceptions back to the

Exception slipping exception handler

為{幸葍}努か 提交于 2019-12-25 05:09:11
问题 I got the following exception in my page: Fatal error: Call to a member function someFunction() on a non-object in seomfile.php on line 15 My code near line 15 is: try { return getObject()->someFunction(); // line 15 } catch(Exception $e) { } I know getObject() returns null, but why isn't the try block catching it? 回答1: PHP mixes Exceptions and Errors. You could use set_error_handler() to throw an exception on error. 回答2: You can try to use something like this: try { $object = getObject(); If

At what level and how is appropriate to catch exceptions

雨燕双飞 提交于 2019-12-25 05:05:21
问题 I know this is subjective, but should exceptions be caught in the lowest level or higher. I ask because I usually do try { //.. } catch { //LOG } So when I implement some "low level" function, like std::string read_from_file(const std::string& file_name); Im not sure what should I do: 1) let caller handle exception. 2) catch (log?) and rethrow 3) catch and change function so that bool is return type(last line in try is return true; last line in catch is return false;). I dont like this but

At what level and how is appropriate to catch exceptions

喜欢而已 提交于 2019-12-25 05:05:10
问题 I know this is subjective, but should exceptions be caught in the lowest level or higher. I ask because I usually do try { //.. } catch { //LOG } So when I implement some "low level" function, like std::string read_from_file(const std::string& file_name); Im not sure what should I do: 1) let caller handle exception. 2) catch (log?) and rethrow 3) catch and change function so that bool is return type(last line in try is return true; last line in catch is return false;). I dont like this but

Self-error-dependent self-disposal of IObservable subscriptions

霸气de小男生 提交于 2019-12-25 05:04:26
问题 I have F# code that looks like this: module O = Control.Observable //... use ss = serve' 4000 |> O.subscribe (fun c -> use cs = RSS.items |> O.subscribe (bytes >> c.SendAll) |> ignore) where serve' : int -> IObservable<Socket> c : Socket RSS.items : IObservable<XElement> bytes : XElement -> byte [] c.SendAll : byte [] -> unit What is the most idiomatic way to retain cs until c.SendAll fails? Is there or is it possible to define Observable.subscribeUntilError(action) where if action fails,

java.lang.ExceptionInInitializerError | Caused by: com.b.a.c.b: 'com.b.a.b.a' requires the 'sequence' attribute

时光总嘲笑我的痴心妄想 提交于 2019-12-25 03:34:08
问题 I am getting following exception in different areas of my project. And worst thing is I have no idea what it is... I do not have com.b.a.c.b package in my project. I tried searching on web but still, I am not understanding what is causing this exception. This exception is thrown on onCreate() method (I guess) after an Intent call from another Activity . Note: I am using gson 2.2.4 with POJO method, just before this I got this exception, I was facing error in JSON creation with same kind of

Get Full Exception Error with Flex

一世执手 提交于 2019-12-25 01:49:50
问题 I can't use trace because I'm not using an Adobe IDE and when I try to view my exception errors, I can't seem to get the full error message, I only seem to get the "errorID". For example, if I had a 1069 error, I should see something like: Error #1069: Property data not found on X and there is no default value. But instead I see this... ReferenceError: Error #1069 This is my code... try { //error gets thrown here } catch(e:Error) { extTrace('Error: '+e.toString());//I also tried e.message, e

Java method throwing exception

巧了我就是萌 提交于 2019-12-25 01:27:03
问题 I have a java method which is potent of throwing multiple unchecked exceptions. My question is: do I need to declare it to throw all the the exceptions or Is there any problem if I declare throws Exception only? Method 1: public void myMethod() throws Exception1,Exception2,Exception3,Exception4,Exception5 {} Instead of method 1, can I declare like this? public void myMethod() throws Exception {} 回答1: Yes you can, but ideally people choose a specific type of Exception so that you know which