{"id":21556935,"url":"https://github.com/mansartesteban/error-handler","last_synced_at":"2025-03-18T03:22:36.985Z","repository":{"id":62523471,"uuid":"174380265","full_name":"mansartesteban/error-handler","owner":"mansartesteban","description":null,"archived":false,"fork":false,"pushed_at":"2019-03-11T11:05:42.000Z","size":45,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-24T10:32:18.600Z","etag":null,"topics":["error","exception","handler","php","throwable"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mansartesteban.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-07T16:22:15.000Z","updated_at":"2024-07-22T15:07:35.000Z","dependencies_parsed_at":"2022-11-02T13:47:23.117Z","dependency_job_id":null,"html_url":"https://github.com/mansartesteban/error-handler","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mansartesteban%2Ferror-handler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mansartesteban%2Ferror-handler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mansartesteban%2Ferror-handler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mansartesteban%2Ferror-handler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mansartesteban","download_url":"https://codeload.github.com/mansartesteban/error-handler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244147754,"owners_count":20406042,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["error","exception","handler","php","throwable"],"created_at":"2024-11-24T08:10:22.376Z","updated_at":"2025-03-18T03:22:36.967Z","avatar_url":"https://github.com/mansartesteban.png","language":"PHP","readme":"# Language\n\n[Français](readme/README.fr.md)\n\n# Presentation\n\nThis libs make you ablde to handle Exceptions. It create log files sorted by date and type.\nErrorHandler provide a parsing system for log file to display beautiful interface (Inprogress)\n\n# Documentation\n\n## Methods\n\n```php\nErrorHandler::init($options = []);\nErrorHandler::isCreated();\nErrorHandler::log($type = \"\", Exception $ex, mixed $additionalParameters = null);\n```\n\n## Options\n\n```php \nErrorHandler::init($options = []);\n```\nAt initialization, you have to pass as parameter an options array to define the behavior of you handler, otherwise it will throw a _LogicException_\n\n```php\n$options = [\n  \"logDir\" =\u003e \"/log\", // Path to directory which contains log files\n  \"cssClass\" =\u003e \"errorHandler-log\", // CSS class name that delimitate a log section\n];\n ```\n**`logDir`** is a `string` you define. If it ends by \"/\", the \"/\" will be ignored (_Ex: \"/private/log\", \"/log\", \"/engine/error/log/\", ..._) \n \n **`cssClass`** is `string`you define (_Ex: \"log\", \"error-log\", \"admin-log-section\", ..._)\n___________\n\n```php\nErrorHandler::log($type = \"\", Exception $ex, $additionalParameters = null)\n```\n**`type`** is a _`string`_ which define the error type. It is used to create sub-diirectory in $options[\"_logDir_\"] (_Ex: \"PDO\", \"PHP\", \"API_FACEBOOK\", ..._)\n\n**`ex`** is an _`Exception`_ that you catch or instanciate. You can pass any Exception type herited.\n\n\n## Examples\n\n### Initialization\n\n```php\n//File : /src/config/initClasses.php\n\n$optionsErrorHandler = [\n  \"logDir\" =\u003e \"/private/log\",\n  \"cssClass\" =\u003e \"log-error\"\n];\n\nif (!ErrorHandler::isCreated()) {\n  ErrorHandler::init($optionsErrorHandler);\n}\n```\n\n### Log an Exception\n\n```php\n// Exemple 1 :\ntry {\n  // your code here ...\n} catch (PDOException $ex) {\n  ErrorHandler::log(\"PDO\", $ex, [$sqlReq, $sqlParams]);\n}\n\n// Exemple 2 :\nif ($url == null) {\n  ErrorHandler::log(\"logic\", new LogicExepction(\"url for cURL request is null\"));\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmansartesteban%2Ferror-handler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmansartesteban%2Ferror-handler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmansartesteban%2Ferror-handler/lists"}