chromium/third_party/blink/renderer/modules/ai/exception_helpers.cc

// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "third_party/blink/renderer/modules/ai/exception_helpers.h"

#include "base/debug/dump_without_crashing.h"
#include "base/notreached.h"
#include "third_party/blink/public/mojom/ai/ai_manager.mojom-shared.h"
#include "third_party/blink/renderer/core/dom/dom_exception.h"
#include "third_party/blink/renderer/platform/bindings/exception_code.h"

namespace blink {

const char kExceptionMessageExecutionContextInvalid[] =;
const char kExceptionMessageServiceUnavailable[] =;

const char kExceptionMessagePermissionDenied[] =;
const char kExceptionMessageGenericError[] =;
const char kExceptionMessageFiltered[] =;
const char kExceptionMessageDisabled[] =;
const char kExceptionMessageCancelled[] =;
const char kExceptionMessageSessionDestroyed[] =;

const char kExceptionMessageInvalidTemperatureAndTopKFormat[] =;
const char kExceptionMessageUnableToCreateSession[] =;
const char kExceptionMessageUnableToCloneSession[] =;
const char kExceptionMessageRequestAborted[] =;

void ThrowInvalidContextException(ExceptionState& exception_state) {}

void ThrowSessionDestroyedException(ExceptionState& exception_state) {}

void RejectPromiseWithInternalError(ScriptPromiseResolverBase* resolver) {}

DOMException* CreateInternalErrorException() {}

namespace {
// Create an UnknownError exception, include `error` in the exception
// message. This is intended for handling values of
// `ModelStreamingResponseStatus` that we do not expect to ever see when
// using an on-device model, e.g. errors related to servers.
DOMException* CreateUnknown(const char* error) {}
}  // namespace

DOMException* ConvertModelStreamingResponseErrorToDOMException(
    ModelStreamingResponseStatus error) {}

// LINT.IfChange(ConvertModelAvailabilityCheckResultToDebugString)
WTF::String ConvertModelAvailabilityCheckResultToDebugString(
    mojom::blink::ModelAvailabilityCheckResult result) {}
// LINT.ThenChange(//third_party/blink/public/mojom/ai_manager.mojom:ModelAvailabilityCheckResult)

}  // namespace blink