Example #1
0
        /// <summary>
        /// Triggers the error by passing it to
        /// the user handler first (<see cref="PhpCoreConfiguration.UserErrorHandler"/> and then to
        /// the internal handler (<see cref="Throw(PhpError, string)"/>.
        /// </summary>
        public static void TriggerError(Context ctx, PhpError error, string message)
        {
            if (ctx == null)
            {
                throw new ArgumentNullException(nameof(ctx));
            }

            if (message == null)
            {
                message = string.Empty;
            }

            // try the user handler
            var config = ctx.Configuration.Core;

            if (config.UserErrorHandler != null && (config.UserErrorTypes & error) != 0)
            {
                var trace = new PhpStackTrace();

                if (!config.UserErrorHandler.Invoke(ctx, (int)error, message, trace.GetFilename(), trace.GetLine(), PhpValue.Null).IsFalse)
                {
                    return;
                }
            }

            // fallback to internal handler
            Throw(error, message);
        }
Example #2
0
        public Exception(string message = "", long code = 0, Throwable previous = null)
            : base(message, innerException: previous as System.Exception)
        {
            _stacktrace = new PhpStackTrace();

            this.file = _stacktrace.GetFilename();
            this.line = _stacktrace.GetLine();

            __construct(message, code, previous);
        }