Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122291 Return-Path: <6562680@gmail.com> Delivered-To: mailing list internals@lists.php.net Received: (qmail 64947 invoked from network); 6 Feb 2024 13:58:20 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 6 Feb 2024 13:58:20 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1707227952; bh=/SvRMfTleazUo2EX2noCRn8kWQWVIeF19I7SNsUwozY=; h=From:Date:Subject:To:From; b=dPthfUW3TrOP0wg5JRDJGDnKz7/+fm7Oft+tWUHoteBrSfRnHkaNivaRwThOIX6op q+ufMJ0r+RWe9zb1aA6HpWD+aIqrJ8na3k/HTO6ZEhAknLkZuTiusPQfUiJZFutvkx 3QD/NmVGlX9ZFfW9JRb0A9itKCPE+EELGOMZGXZNZOrRs9U70Y/i6M/ubKZ02u03pO aGX8lmrF0tKtJqos72XlfQ0utDS9nILY5tGkjsBsWfrJI8n5sm9LY7VZjp9wNrQd+p 5ce+O7W6pFh1dDwLB5SKFnPKY4rRgQv5o0wXWcabs9DxbAoJ0ea6f5y6P0CwwXEOCp i76iuCROX61wA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2E84018005A for ; Tue, 6 Feb 2024 05:59:11 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: * X-Spam-Status: No, score=1.5 required=5.0 tests=BAYES_40,BODY_8BITS, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: <6562680@gmail.com> Received: from mail-oo1-f44.google.com (mail-oo1-f44.google.com [209.85.161.44]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 6 Feb 2024 05:59:10 -0800 (PST) Received: by mail-oo1-f44.google.com with SMTP id 006d021491bc7-594cb19c5d9so223845eaf.0 for ; Tue, 06 Feb 2024 05:58:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707227898; x=1707832698; darn=lists.php.net; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=/SvRMfTleazUo2EX2noCRn8kWQWVIeF19I7SNsUwozY=; b=kkN/nSAGaIKtRYEBRgJPxye+uuVWCzCQPE97Ypd31+0iaJ2CiMQkPfrqppuFvm2fXu u9e3zDkqOOQFcwOZmWneeh4xMamwW38pv8KytDHKNrTq5hoaLSvlH3CVax1VGEzt/2ic CBK52gWrQ4GLe7OA7fBq9ggNTFL5wOf/d9+MJ1u6dT+hdPoEaBfNNh9Y6Yb7A1Hsm/um 4KqC1vkSscDYi+7p8At/x6/0f396BRl4Hu7sk6G34Kck4RSLz1j5Egh92KPRjQZAQ5Ou McTHZ0byi72YP/7VWOP/mL4Zy7wA+fsUJ0J9TBXV6pVAUcWy2zjN1dojfWLq6cSPTaRE bpqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707227898; x=1707832698; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=/SvRMfTleazUo2EX2noCRn8kWQWVIeF19I7SNsUwozY=; b=w9jO/TtNpXq39E2ftp6+uvvXvy1I3W3XYATB3j7l1NlEKKZGYQtt0tbFB1DzY8F4l3 hzMl36DcqP799hQfQO2v4p+rl+RCL6/g46M1TWgYIar6pXS87QSNaacg50B57Z7wMAOq QQ8BLCsgyZV1Z332fxIId0tht6uAs9OaqbZn5sZXwc9978iCRwsR+nIDuOqFXsLuHFeV kya5AGvY87FNSXH0S3rvqw7EmRpL589sYv3bymDXh1j/XUrqVxJAq9idi/xvAsyk88Hy B+ydUb9gZSFIBwxErwGDl61JjWbiVrenjvzN5ASZjXn+uADxQIIfFuR2ebFA+2hXNbeU Emzw== X-Gm-Message-State: AOJu0YxObR2W3Z95NUgKE/D4/fuitEIqpI8uEOEdCstv8ZQ7VscNJUS3 0gW1y4NNL+Vij3K+fba/CEM7JEF8+iZRaKrH49eqS9QRj+61Z54xSwRfMMGf2HgFgFXbmvIPesn m5GivjJhrVD0mFpWUgPSO4D1FSlWU2hBY1xWGU1hc X-Google-Smtp-Source: AGHT+IGI2Cy3Y880ykuIWXAX3te9p4PJGiU4wjMmkKH7lNRURh5Eg0DQv5lt31AUUo1Q3z5ejRzHVMLDChe+844qeWM= X-Received: by 2002:a05:6870:8a0f:b0:219:4d13:76d0 with SMTP id p15-20020a0568708a0f00b002194d1376d0mr1250238oaq.11.1707227897894; Tue, 06 Feb 2024 05:58:17 -0800 (PST) MIME-Version: 1.0 =?UTF-8?B?Yg==?= <6562680@gmail.com> Date: Tue, 6 Feb 2024 16:57:42 +0300 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary="000000000000679c720610b6f8fa" Subject: Feature request: https://github.com/php/php-src/issues/13301 From: 6562680@gmail.com (=?UTF-8?B?0JPRgNC40LPQvtGA0LjQuSBTZW5pb3IgUEhQIC8g0KDQsNC30YDQsNCx0L7RgtGH0LjQuiBXZQ==?==?UTF-8?B?Yg==?=) --000000000000679c720610b6f8fa Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hello, please discuss about error collecting implementation in next PHP releases Exceptions have common differences that restrict using them to collect errors 1. Timeloss (trace collection) on call new() on any class that implements \Throwable 2. To collect errors and return it to the upper level you have to change the return signature, so most of the time rewrite the full tree and change all signatures, that's inapplicable and causes more refactor time without any benefits 3. Exceptions will break code, so you need to catch them as much closely as possible to place you throw it (additional refactoring) What I want from this feature: - while I am writing the api, I need not only "log" the errors, but be able to send all script errors to json output, including warnings, errors, and deep nested. It will reduce the time of debugging, otherwise i have to download log files from server or configure external system like sentry that collects all errors by groups/chains Suggested solution: - add non-breakable interface and language construct `raise` to "throw" error without collecting trace - that error could be any scalar or object, or you can implement new interface for them, keeping that is nested and taggable array - this `raise` could be catched same way as \Throwable allowing log it anywhere you need or re-`raise` again - `raise` statement won't start to collapse/break code, so it could be skipped without affecting application Current solution: a) 2 classes - ErrorBag/ErrorBagStack. b) native functions like _error()/_warning() that stores errors to the current ErrorBag if it exists. c) ErrorBag exists only if you initialize it: - from the upper level (you need to collect) - directly inside a function (you need to decide return/continue depending on its emptiness) - otherwise _error()/_warning() does nothing d) once you "catch" results of _error()/_warning() you often need it to merge the result to the current errorbag, mark it with a nesting group or with the tag. Nesting group is required once you debug code (you will see the log), tags will needed once you want to copy results from one bag to another (closest example - reduce queue with unique function, do action, then work with initial data) e) useful feature is merge_as_warning($errorBag) - to prevent the current error bag to return `true` on call ->hasErrors(). Errors are related to low level function, and possibly you already do actions that allow you just store them. f) searching inside the error bag by nesting sequence, or by tag, or by error type. Error type helps the same as try/catch, tag helps if you want to save errors to several destinations without memory losses, and nesting will help most of the time in debugging. Thanks for your attention. --=20 +375 (29) 676-48-68 <+375296764868> / Mobile - =D0=BF=D1=80=D0=B5=D0=B4=D0= =BF=D0=BE=D1=87=D0=B8=D1=82=D0=B0=D0=B5=D0=BC=D1=8B=D0=B9 =D1=81=D0=BF=D0= =BE=D1=81=D0=BE=D0=B1 =D1=81=D0=B2=D1=8F=D0=B7=D0=B8 https://t.me/gzhegow / https://t.me/%2B375296764868 / Telegram 6562680@gmail.com --000000000000679c720610b6f8fa--