summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/cocoa/applescript/error_applescript.mm
blob: 327c57fe0927867e3ff9ebe5681bbde9e3a26e23 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright (c) 2011 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.

#import "chrome/browser/ui/cocoa/applescript/error_applescript.h"

#include "base/logging.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util_mac.h"

void AppleScript::SetError(AppleScript::ErrorCode errorCode) {
  using l10n_util::GetNSString;
  NSScriptCommand* current_command = [NSScriptCommand currentCommand];
  [current_command setScriptErrorNumber:(int)errorCode];
  NSString* error_string = @"";
  switch (errorCode) {
    case errGetProfile:
      error_string = GetNSString(IDS_GET_PROFILE_ERROR_APPLESCRIPT_MAC);
      break;
    case errBookmarkModelLoad:
      error_string = GetNSString(IDS_BOOKMARK_MODEL_LOAD_ERROR_APPLESCRIPT_MAC);
      break;
    case errCreateBookmarkFolder:
      error_string =
          GetNSString(IDS_CREATE_BOOKMARK_FOLDER_ERROR_APPLESCRIPT_MAC);
        break;
    case errCreateBookmarkItem:
      error_string =
          GetNSString(IDS_CREATE_BOOKMARK_ITEM_ERROR_APPLESCRIPT_MAC);
        break;
    case errInvalidURL:
      error_string = GetNSString(IDS_INVALID_URL_APPLESCRIPT_MAC);
      break;
    case errInitiatePrinting:
      error_string = GetNSString(IDS_INITIATE_PRINTING_ERROR_APPLESCRIPT_MAC);
      break;
    case errInvalidSaveType:
      error_string = GetNSString(IDS_INVALID_SAVE_TYPE_ERROR_APPLESCRIPT_MAC);
      break;
    case errInvalidMode:
      error_string = GetNSString(IDS_INVALID_MODE_ERROR_APPLESCRIPT_MAC);
      break;
    case errInvalidTabIndex:
      error_string = GetNSString(IDS_INVALID_TAB_INDEX_APPLESCRIPT_MAC);
      break;
    case errSetMode:
      error_string = GetNSString(IDS_SET_MODE_APPLESCRIPT_MAC);
      break;
    case errWrongIndex:
      error_string = GetNSString(IDS_WRONG_INDEX_ERROR_APPLESCRIPT_MAC);
      break;
    default:
      NOTREACHED();
  }
  [current_command setScriptErrorString:error_string];
}