小编Ali*_*Ali的帖子

在 Laravel 5.3 中创建自定义异常类和自定义处理程序类

在进入代码之前,让我解释一下我的目标。我的网络应用程序显示待售车辆。如果用户尝试访问不存在的页面,我需要一个自定义 404 页面,该页面将显示添加到数据库中的 12 辆最新车辆。

我有以下...

App\Exceptions\CustomException.php

<?php

namespace App\Exceptions;

use Exception;

class CustomException extends Exception
{
    public function __construct()
    {
        parent::__construct();
    }
}
Run Code Online (Sandbox Code Playgroud)

App\Exceptions\CustomHandler.php

<?php
namespace App\Exceptions;

use Exception;
use App\Exceptions\Handler as ExceptionHandler;
use Illuminate\Contracts\Container\Container;
use App\Project\Frontend\Repo\Vehicle\EloquentVehicle;
use Illuminate\Foundation\Exceptions\Handler;
use Illuminate\Support\Facades\View;

class CustomHandler extends ExceptionHandler
{
    protected $vehicle;

    public function __construct(Container $container, EloquentVehicle $vehicle)
    {
        parent::__construct($container);

        $this->vehicle = $vehicle;
    }

    /**
     * Report or log an exception.
     *
     * This is a great spot to send exceptions to Sentry, …
Run Code Online (Sandbox Code Playgroud)

exception laravel laravel-5

7
推荐指数
3
解决办法
3万
查看次数

尝试使用Facebook SDK时Gradle构建失败

我试图在Android Studio的项目中使用Facebook SDK.我正在按照教程的第3步进行操作.当我尝试运行应用程序时,我得到一个"Gradle:执行失败的任务':FacebookApp:dexDebug'." 错误.如果错误,下面是输出

Gradle: Execution failed for task ':FacebookApp:dexDebug'.
> Failed to run command:
C:\android-sdk\build-tools\18.0.0\dx.bat --dex --output C:\Users\Brandon\AndroidStudioProjects\FacebookAppProject\FacebookApp\build\libs\FacebookApp-debug.dex C:\Users\Brandon\AndroidStudioProjects\FacebookAppProject\FacebookApp\build\classes\debug C:\Users\Brandon\AndroidStudioProjects\FacebookAppProject\FacebookApp\build\dependency-cache\debug C:\Users\Brandon\AndroidStudioProjects\FacebookAppProject\FacebookApp\build\exploded-bundles\FacebookAppProjectLibrariesFacebookUnspecified.aar\classes.jar C:\Users\Brandon\AndroidStudioProjects\FacebookAppProject\FacebookApp\build\exploded-bundles\FacebookAppProjectLibrariesFacebookUnspecified.aar\libs\android-support-v4.jar C:\android-sdk\extras\android\m2repository\com\android\support\support-v4\13.0.0\support-v4-13.0.0.jar
    Error Code:
        1
    Output:
        UNEXPECTED TOP-LEVEL EXCEPTION:
        java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoIcsImpl;
            at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
            at com.android.dx.dex.file.DexFile.add(DexFile.java:163)
            at com.android.dx.command.dexer.Main.processClass(Main.java:490)
            at com.android.dx.command.dexer.Main.processFileBytes(Main.java:459)
            at com.android.dx.command.dexer.Main.access$400(Main.java:67)
            at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:398)
            at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:245)
            at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:131)
            at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109)
            at com.android.dx.command.dexer.Main.processOne(Main.java:422)
            at com.android.dx.command.dexer.Main.processAllFiles(Main.java:333)
            at com.android.dx.command.dexer.Main.run(Main.java:209)
            at com.android.dx.command.dexer.Main.main(Main.java:174)
            at com.android.dx.command.Main.main(Main.java:91)
        1 error; aborting
Run Code Online (Sandbox Code Playgroud)

这是facebook模块的build.gradle:

buildscript {
    repositories {
        maven { url 'http://repo1.maven.org/maven2' }
    }
    dependencies …
Run Code Online (Sandbox Code Playgroud)

android facebook gradle android-studio

6
推荐指数
1
解决办法
1万
查看次数