<?php namespace Maduser\Minimal\Database\Exceptions;

use Maduser\Minimal\Exceptions\MinimalException;

/**
 * Class Exception
 *
 * @package Maduser\Minimal\Database\DatabaseException
 */
class DatabaseException extends MinimalException
{
    /**
     * @return mixed
     */
    public function getMyFile()
    {
        if ($this->isMessageObject()) {
            return $this->myMessage->getFile();
        }

        $t = debug_backtrace();

        $item = $t[0];
        $item = isset($t[1]) && isset($t[1]['file']) ? $t[1] : $item;
        $item = isset($t[2]) && isset($t[2]['file']) ? $t[2] : $item;
        $item = isset($t[3]) && isset($t[3]['file']) ? $t[3] : $item;

        return $item['file'];
    }

    /**
     * @return mixed
     */
    public function getMyLine()
    {
        if ($this->isMessageObject()) {
            return $this->myMessage->getLine();
        }

        $t = debug_backtrace();

        $item = $t[0];
        $item = isset($t[1]) && isset($t[1]['file']) ? $t[1] : $item;
        $item = isset($t[2]) && isset($t[2]['file']) ? $t[2] : $item;
        $item = isset($t[3]) && isset($t[3]['file']) ? $t[3] : $item;

        return $item['line'];
    }
}
<?php namespace Maduser\Minimal\Database\Exceptions;

use Maduser\Minimal\Exceptions\MinimalException;

/**
 * Class Exception
 *
 * @package Maduser\Minimal\Database\DatabaseException
 */
class DatabaseException extends MinimalException
{
    /**
     * @return mixed
     */
    public function getMyFile()
    {
        if ($this->isMessageObject()) {
            return $this->myMessage->getFile();
        }

        return debug_backtrace()[3]['file'];
    }

    /**
     * @return mixed
     */
    public function getMyLine()
    {
        if ($this->isMessageObject()) {
            return $this->myMessage->getLine();
        }

        return debug_backtrace()[3]['line'];
    }
}
--- 
+++ 
@@ -18,7 +18,14 @@
             return $this->myMessage->getFile();
         }
 
-        return debug_backtrace()[3]['file'];
+        $t = debug_backtrace();
+
+        $item = $t[0];
+        $item = isset($t[1]) && isset($t[1]['file']) ? $t[1] : $item;
+        $item = isset($t[2]) && isset($t[2]['file']) ? $t[2] : $item;
+        $item = isset($t[3]) && isset($t[3]['file']) ? $t[3] : $item;
+
+        return $item['file'];
     }
 
     /**
@@ -30,6 +37,13 @@
             return $this->myMessage->getLine();
         }
 
-        return debug_backtrace()[3]['line'];
+        $t = debug_backtrace();
+
+        $item = $t[0];
+        $item = isset($t[1]) && isset($t[1]['file']) ? $t[1] : $item;
+        $item = isset($t[2]) && isset($t[2]['file']) ? $t[2] : $item;
+        $item = isset($t[3]) && isset($t[3]['file']) ? $t[3] : $item;
+
+        return $item['line'];
     }
 }
Test trace for file until index 3
