Skip to content

Instantly share code, notes, and snippets.

View Bachsau's full-sized avatar

Bachsau

View GitHub Profile
@Bachsau
Bachsau / stop_dangerous_names.php
Last active August 27, 2020 19:37
Stop PHP’s dangerous name handling
<?php
// Stop PHP’s dangerous name handling
function undefined_name_error($errno, $errstr, $errfile='', $errline=0, $errcontext=NULL) {
if (stripos($errstr, 'Undefined') !== false) {
error_log("PHP Fatal error: $errstr in $errfile on line $errline");
exit(255);
}
else {
return false;
@Bachsau
Bachsau / virtual_oserror.py
Last active May 27, 2020 01:02
A custom exception class that closely resembles Python’s OSError
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# A custom exception class that closely resembles the behavior of
# Python’s built-in OSError, including arguments and automatic
# subclassing. Useful if a fine-grained error handling based on
# error numbers is needed.
class VirtualOSError(Exception):
"""Base exception for all virtual OS related errors.