exception-handling

Catching an exception when creating a new SoapClient properly

不打扰是莪最后的温柔 提交于 2019-12-11 19:42:25
问题 I'm having a difficult time catching a SoapClient authentication issue. When my code executes, Laravel declares it's throwing an ErrorException but I can't seem to catch it no matter what code I use. I'm tagging Laravel in case there's some magic going on somewhere I don't know about because App::error() will trigger on this error still. try { $client = new SoapClient( $this->serviceUrl . $this->clients[$clientName], array( 'login' => $this->username, 'password' => $this->password,

Try-Catch inside While Loop

怎甘沉沦 提交于 2019-12-11 18:52:55
问题 The code below asks the user how many racers he/she would like. while (true) { // loops forever until break try { // checks code for exceptions System.out.println("How many racers should" + " participate in the race?"); amountRacers = in.nextInt(); break; // if no exceptions breaks out of loop } catch (InputMismatchException e) { // if an exception appears prints message below System.err.println("Please enter a number! " + e.getMessage()); continue; // continues to loop if exception is found

How to handle php errors and exceptions centrally

旧时模样 提交于 2019-12-11 18:16:08
问题 previously in PHP 4 i created a custom error handler (below) to handle my own triggered errors and general PHP errors. But now PHP 5 introduces Exceptions i.e. I'm leveraging PDO for database manipulation and I'm not sure how to handle both general PHP errors and these Exceptions? function errorHandler($errno, $errstr, $errfile, $errline){ switch ($errno) { case E_USER_ERROR: // Send an e-mail to the administrator error_log("Error: $errstr \n Fatal error on line $errline in file $errfile \n",

Entity types cannot be generic

元气小坏坏 提交于 2019-12-11 18:13:20
问题 I am using the following function in the Domain Service, public IQueryable<Dictionary<discussion_category, List<discussion_board>>> GetDiscussion_categoriesWithBoards() { return new[] { GetDiscussion_categories().Select(c => new { Category = c, Boards = GetDiscussion_boardsByCategory(c.ID).ToList() }).ToDictionary(i => i.Category, i => i.Boards.ToList()) }.AsQueryable(); } seems to have no errors and i get the following error while compiling, Type 'Dictionary`2' is not a valid entity type.

Customy Exception Control not working anymore after update to Symfony 2.8

為{幸葍}努か 提交于 2019-12-11 18:08:02
问题 I have just updated my Symfony 2.7 page to 2.8. Beside Symfony itself a number of other packages (e.g. FOSUserBundle , FOSRestBundle , Doctrine , etc.) have been updated as well. After the Update my CustomExceptionController does not work any more. Error like 404 or 500 show the default exception page instead of my custom page. Before the Update my CustomExceptionController worked without any problem. This is the configuration: // app/config/config.yml ... twig: exception_controller: app

Solve NullReference exception

依然范特西╮ 提交于 2019-12-11 17:33:51
问题 I use crystal report to implement reporting in my c# windows application.I create a form to show print preview of Report.I use following code to show preview: private ReportDocument _reportDocument; public CrystalReportPrintPreviewForm(ReportDocument reportDocument) { InitializeComponent(); _reportDocument = reportDocument; } private void CrystalReportPrintPreviewForm_Load(object sender, EventArgs e) { if(_reportDocument!=null) crystalReportViewer1.ReportSource = _reportDocument; } And also i

“Argument expression is not valid” error with EF4 Linq sub select query

浪尽此生 提交于 2019-12-11 17:17:06
问题 Any ideas as to why this query compiles, but then throws this runtime error: Argument expression is not valid I know I could change my db model, but in this case it's not possible. Any ideas how to get something like this working? Not even sure what this would be called. Thanks. DBContext db = new DBContext(); var books = (from b in db.BOOKS select new { b.ID, b.NAME, AuthorName = db.PEOPLEs.Where(p=>p.ID==b.AUTHOR).First().USER_ID, }).ToList(); 回答1: I've found I have the best luck with

How to catch JNI Crashes as exceptions using Signal handling based mechanism in Java [duplicate]

为君一笑 提交于 2019-12-11 17:01:37
问题 This question already has answers here : How to catch JNI/Java Exception (2 answers) Closed 4 years ago . I developed a Java tool and it has many JNI functions, I am getting JNI crashes often. Is there any possibility to avoid those crashes or to catch these crashes as exceptions. I surfed internet and found it is possible through signal processing, signal chanining, sigaction(), etc. But I could not get a reliable source to direct me. Please do guide me on this. 回答1: JNI exceptions are

proper way to read user input from command line in java

蓝咒 提交于 2019-12-11 16:47:49
问题 I was hoping to get some opinions regarding best practices and comments on the way I read user input from the command line. Is there a recommended way to do this, am I using the try/catch blocks properly? My example here works fine, but would still like to hear if there is a 'cleaner' way to do this. Many thanks. For example are he return statements in each catch block necessary? Or, should I put my logic (the conditionals) within the try block? public class Client { public static void main

Python: Exception in the separated module works wrong

落爺英雄遲暮 提交于 2019-12-11 16:24:22
问题 I've created new exception class and I like to give it representation of errors like in OSError class. Here is what I want: >>> raise(MyError(1, 'info')) MyError: [Errno 1] predefined text: info What should I do? Can I do this if I inherit from base Exception class? Here is what I've tried (example from module for work with gnulib): class GNULibError(Exception): '''Exception handler for GNULib classes.''' def __init__(self, errno, errinfo=None): '''Each error has following parameters: errno: