Unhandled Exception Phpstorm



-->

  1. Unhandled Exception Caught
  2. Windows 10 3dxvirtualcd Unhandled Exception

The common language runtime allows most unhandled exceptions in threads to proceed naturally. In most cases this means that the unhandled exception causes the application to terminate.

The common language runtime provides a backstop for certain unhandled exceptions that are used for controlling program flow:

  • Artem's presentation is here: is the IDE for PHP and web de.
  • Released: Nov 29, 2017. Updates in 2017.3 Features. Editor-based REST client. New REST client interface - With the new REST client, all the powers of the PhpStorm code editor are now available for your REST requests.Use code completion to assist you with composing a request, apply refactorings to it, store the request as part of the project and add it to VCS, execute the request, and examine.
Exception

Inspection in version 2018.3 now warns about unhandled exceptions on the default DateTime constructor with no arguments. Is this really necessary? What would be the best way to make PhpStorm happy? Add an empty try-catch? I don't really want to add @throws tags to my functions when I know they won't throw anything 😕. PHP 7.1.0RC6 with xdebug 2.5.0rc1 under PHPStorm 10 and 2016.3. In PHPStorm, when starting a debugging session, a message 'Connection with 'xdebug 2.5.0rc1' was not established' is first displayed with a link to 'Validate the installation'. Unhandled exception thrown: read access violation. If there is a handler for this.

  • A ThreadAbortException is thrown in a thread because Abort was called.

  • An AppDomainUnloadedException is thrown in a thread because the application domain in which the thread is executing is being unloaded.

  • The common language runtime or a host process terminates the thread by throwing an internal exception.

Unhandled

If any of these exceptions are unhandled in threads created by the common language runtime, the exception terminates the thread, but the common language runtime does not allow the exception to proceed further.

If these exceptions are unhandled in the main thread, or in threads that entered the runtime from unmanaged code, they proceed normally, resulting in termination of the application.

Note

It is possible for the runtime to throw an unhandled exception before any managed code has had a chance to install an exception handler. Even though managed code had no chance to handle such an exception, the exception is allowed to proceed naturally.

Exposing Threading Problems During Development

When threads are allowed to fail silently, without terminating the application, serious programming problems can go undetected. This is a particular problem for services and other applications that run for extended periods. As threads fail, program state gradually becomes corrupted. Application performance may degrade, or the application might become unresponsive.

Allowing unhandled exceptions in threads to proceed naturally, until the operating system terminates the program, exposes such problems during development and testing. Error reports on program terminations support debugging.

Change from previous versions

In .NET Framework versions 1.0 and 1.1, the common language runtime provides a backstop for unhandled exceptions in the following situations:

Phpstorm
  • There is no such thing as an unhandled exception on a thread pool thread. When a task throws an exception that it does not handle, the runtime prints the exception stack trace to the console and then returns the thread to the thread pool.

  • There is no such thing as an unhandled exception on a thread created with the Start method of the Thread class. When code running on such a thread throws an exception that it does not handle, the runtime prints the exception stack trace to the console and then gracefully terminates the thread.

  • There is no such thing as an unhandled exception on the finalizer thread. When a finalizer throws an exception that it does not handle, the runtime prints the exception stack trace to the console and then allows the finalizer thread to resume running finalizers.

The foreground or background status of a managed thread does not affect this behavior.

For unhandled exceptions on threads originating in unmanaged code, the difference is more subtle. The runtime JIT-attach dialog preempts the operating system dialog for managed exceptions or native exceptions on threads that have passed through native code. The process terminates in all cases.

Migration

If you are migrating from .NET Framework 1.0 or 1.1 and took advantage of the runtime backstop, for example to terminate threads, consider one of the following migration strategies:

  • Restructure the code so the thread exits gracefully when a signal is received.

  • Use the Thread.Abort method to abort the thread.

  • If a thread must be stopped so that process termination can proceed, make the thread a background thread so that it is automatically terminated on process exit.

In all cases, the strategy should follow the design guidelines for exceptions. See Design Guidelines for Exceptions.

As a temporary compatibility measure, administrators can place a compatibility flag in the <runtime> section of the application configuration file. This causes the common language runtime to revert to the behavior of versions 1.0 and 1.1.

Unhandled Exception Phpstorm

Host Override

An unmanaged host can use the ICLRPolicyManager interface in the Hosting API to override the default unhandled exception policy of the common language runtime. The ICLRPolicyManager::SetUnhandledExceptionPolicy function is used to set the policy for unhandled exceptions.

See also

The page and all the pages under this node are available only when the PHP plugin is enabled. The PHP plugin is bundled with PhpStorm and activated by default. If the plugin is disabled, enable it on the Settings/Preferences | Plugins page as described in Managing plugins.

Use this page to configure PHP development and unit testing support in the project by choosing one of the available PHP interpreters, see Configure local PHP interpreters and Configure remote PHP interpreters.

ItemTooltip /
Shortcut
Description
PHP language level

In this list, specify the PHP functionality scope to get coding assistance for. Each functionality scope is associated with the PHP version that supports this functionality. Currently PHP 5.3, PHP 5.4, PHP 5.5, PHP 5.6, PHP 7, PHP 7.1, PHP 7.2, PHP 7.3, PHP 7.4, and PHP 8.0 levels are supported. See supported PHP versions for details.

No correlation between the PHP version used in the project and the language level is enforced. Although the language version of each interpreter is detected automatically, you can still tell PhpStorm to provide you with coding assistance that corresponds to a different language level. However, if you attempt to use a code construct that is not supported by the specified language level, PhpStorm suggests a Switch to PHP <version>quick-fix.

When you open an existing project, PhpStorm analyzes it for the language features used and sets the appropriate language level automatically.

You can also set the PHP language level directly from the status bar.

The list is inactive when the PHP language version is constrained in composer.json and settings synchronization with composer.json is enabled on the Composer page of the Settings/Preferences dialog Ctrl+Alt+S.

CLI Interpreter

In this list, choose the PHP interpreter to use in the current project by default. The list contains all the currently configured local and remote PHP interpreters. See Configure local PHP interpreters and Configure remote PHP interpreters for details.

Shift+Enter

Click this button next to the CLI Interpreter list to create a new PhpStorm-wide PHP installation configuration in the CLI Interpreters dialog that opens.

See Configure local PHP interpreters and Configure remote PHP interpreters for details.

Path mappings

When you configure a remote interpreter accessible through SFTP, Vagrant, Docker, or WSL this read-only field shows the path mappings retrieved from the corresponding deployment configuration, Vagrantfile, or Dockerfile. These mappings are read-only.

To provide the custom mappings, click next to the field and specify them in the Edit Project Path Mappings dialog that opens:

  • To add a custom mapping, click and specify the path in the project and the corresponding path on the remote runtime environment in the Local Path and Remote Path fields respectively. Type the paths manually or click and select the relevant files or folders in the dialog that opens.
  • To remove a custom mapping, select it in the list and click .

Include Path Tab

The area displays the list of configured include paths. Include paths are used for holding third-party code that is used for completion and reference resolution in some functions/methods that use file paths as arguments, for example, require() or include().

  • Use and to add and remove paths.

  • Use and to reorder the items in the list.

  • Click to sort the paths alphabetically in the ascending order.

PHP Runtime Tab

The area lists the available PHP stubs, which are normal, syntactically correct PHP files containing annotated function, method, and class signatures, constant definitions, and so on. PHP stubs are added to PhpStorm's internal knowledge to enhance coding assistance for all the Standard PHP Library components as well as for common extensions.

  • Use the checkboxes next to each item to enable/disable the corresponding stub.

  • To load the set of stubs that matches the set of loaded extensions for the currently configured CLI interpreter, click the Sync Extensions with Interpreter button. For details on configuring interpreters, see Configure local PHP interpreters and Configure remote PHP interpreters.

In the Project tool window, the currently loaded stubs are displayed under the External Libraries node.

PHP stubs are open-source, and you can contribute to their development. See the blog post for details.

Advanced Settings Area

If necessary, you can load a set of custom PHP stubs to be used by PhpStorm. Click next to the Default stubs path field and provide the stubs folder location in the dialog that opens. This way, you can loaPhpStormonal stubs as well as override the bundled ones.

PHP stubs are available as a Composer package, and can thus be declared and installed as a dependency for some third-party package. In this case, they are stored under the vendor/jetbrains/phpstorm-stubs folder inside your project.

To prevent conflicts between the Composer package stubs and PhpStorm bundled stubs, do one of the following:

  • To use the Composer package stubs in your project, explicitly provide the path to their location in the Default stubs path field.

  • To use the PhpStorm's bundled PHP stubs, make sure that the Default stubs path field is cleared and the vendor/jetbrains/phpstorm-stubs folder is excluded from the project.

    • If the Add packages as libraries option is enabled on the PHP | Composer page of the Settings/Preferences dialog Ctrl+Alt+S, PhpStorm automatically marks the vendor/jetbrains/phpstorm-stubs folder as excluded. By default, the option is enabled.

    • If the Add packages as libraries is disabled, you can exclude the stubs package folder manually. To do this, in the Project view, right-click the vendor/jetbrains/phpstorm-stubs folder and select Mark Directory as | Excluded from the context menu.

For details in working with Composer in PhpStorm, refer to Composer dependency manager.

Analysis Tab

Unhandled Exception Caught

Use this tab to configure the behavior of certain PhpStorm inspections.

Exception Analysis

Use this section to configure exception analysis, which alters the behavior of the Unhandled exception, Redundant catch clause, Missing @throws tag(s), and Redundant @throws tag(s) inspections.

ItemTooltip /
Shortcut
Description
Call tree analysis depth

Use this list to set the desired exception analysis depth level. By default, 1 is selected, in which case PhpStorm reports the unhandled exceptions for the parent method throwing an exception, as well as the methods directly calling it. Selecting larger values allows you to drill down deeper into the calls hierarchy.

If 0 is selected, the exception analysis is limited to the parent method.

Values greater than 1 might negatively affect the IDE's performance.

Skip calls with constant params

Select this checkbox to have PhpStorm skip certain method calls in the instance creation expressions during exception analysis:

  • Method calls only having strings or constants as parameters are skipped:

  • Method calls having variables, integers, arrays, and so on as parameters are not skipped:

    $date = new DateTime($myDate);
Unchecked ExceptionsUse this list to specify the exceptions that are treated as unchecked by PhpStorm. Such exceptions are skipped during exception analysis.
Alt+InsertClick this button to add a class to the Unchecked Exceptions list. In the Choose Class dialog that opens, locate the desired class by using the Search by Name tab or the Project tab.
DeleteClick this button to remove a selected class from the Unchecked Exceptions list.

Custom Format Functions

Use this section to include your custom string formatting functions into the Format function parameters mismatch inspection analysis scope. This inspection reports the mismatches between format function parameters and specification conversion entries and by default analyzes the usages of the standard PHP printf and sprintf functions.

ItemTooltip /
Shortcut
Description
Alt+Insert

Click this button to add a new function record to the custom format functions list. In the Add Custom Format Function dialog that opens, provide the name of a class method or function and specify the index of the argument where your formatting template resides.

Delete

Click this button to remove a function record from the custom format functions list.

Enter

Click this button to edit the selected function record.

Include Analysis

Use this section to define a custom folder the $_SERVER['DOCUMENT_ROOT'] expression should resolve to, which alters the behavior of the Unresolved include inspection.

The specified path will be used in code completion for the functions/methods that use file paths as arguments (for example, require() or include() ). If the path is left blank, code completion will suggest the paths relative to the project root.

Commonly, this setting should be modified in case the document root folder defined by your web server configuration is different from the PhpStorm project root folder.

Windows 10 3dxvirtualcd Unhandled Exception

ItemDescription
$_SERVER['DOCUMENT_ROOT'

In this field, provide the folder the $_SERVER['DOCUMENT_ROOT'] expression should resolve to.

The default value is blank: the $_SERVER['DOCUMENT_ROOT'] expression in this case resolves to the project root folder. To have it resolve to a different folder, type the desired folder path relative to the project root, or click and select the desired folder in the dialog that opens.