flutter_flutter/engine/tonic/dart_exception_factory.cc
Adam Barth d8d7db82a0 Really remove config.h
This CL generated by |sed -i '/sky\/engine\/config.h/d'| and a manual sweep to
catch some oddballs.

TBR=eseidel@chromium.org

Review URL: https://codereview.chromium.org/1206763002.
2015-06-23 23:15:28 -07:00

42 lines
1.4 KiB
C++

// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "sky/engine/tonic/dart_exception_factory.h"
#include "sky/engine/tonic/dart_converter.h"
#include "sky/engine/tonic/dart_builtin.h"
#include "sky/engine/wtf/text/StringBuilder.h"
namespace blink {
DartExceptionFactory::DartExceptionFactory(DartState* dart_state)
: dart_state_(dart_state) {
}
DartExceptionFactory::~DartExceptionFactory() {
}
Dart_Handle DartExceptionFactory::CreateNullArgumentException(int index) {
StringBuilder message;
message.appendLiteral("Argument ");
message.appendNumber(index);
message.appendLiteral(" cannot be null.");
return CreateException("ArgumentError", message.toString());
}
Dart_Handle DartExceptionFactory::CreateException(const String& class_name,
const String& message) {
if (core_library_.is_empty()) {
Dart_Handle library = DartBuiltin::LookupLibrary("dart:core");
core_library_.Set(dart_state_, library);
}
Dart_Handle exception_class = Dart_GetType(
core_library_.value(), StringToDart(dart_state_, class_name), 0, 0);
Dart_Handle message_handle = StringToDart(dart_state_, message);
return Dart_New(exception_class, Dart_EmptyString(), 1, &message_handle);
}
} // namespace blink