@Override
        public void onCustomTabsServiceConnected(ComponentName componentName,
                CustomTabsClient client) {
            Uri uri = getUrlForManagingSpace();
            if (uri == null) {
                finish();
                return;
            }

            mSession = client.newSession(mCustomTabsCallback);
            if (mSession == null) {
                onError(new RuntimeException("Failed to create CustomTabsSession"));
                finish();
                return;
            }

            // Warm up is needed for origin verification.
            client.warmup(0);
            mSession.validateRelationship(RELATION_HANDLE_ALL_URLS, uri, null);
        }
Override to implement custom error handling.
customtabs/src/android/support/customtabs/trusted/ManageDataLauncherActivity.java