Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 80 lines (65 sloc) 4.34 kB
a10421a @Watson1978 moved the files from MacRuby's repository
Watson1978 authored
1 SKTUnknownFileReadError = 1
2 SKTUnknownPasteboardReadError = 2
3 SKTWriteCouldntMakeTIFFError = 3
4
5 SKTErrorDomain = "SketchErrorDomain"
6
7 def SKTErrorWithCode (code)
8 # An NSError has a bunch of parameters that determine how it's presented
9 # to the user. We specify two of them here. They're localized strings that
10 # we look up in SKTError.strings, whose keys are derived from the error
11 # code and an indicator of which kind of localized string we're looking
12 # up. The value: strings are specified so that at least something is shown
13 # if there's a problem with the strings file, but really they should never
14 # ever be shown to the user. When testing an app like Sketch you really
15 # have to make sure that you've seen every call of SKTErrorWithCode()
16 # executed since the last time you did things like change the set of
17 # available error codes or edit the strings files.
18 mainBundle = NSBundle.mainBundle
19 localizedDescription = mainBundle.localizedStringForKey(NSString.stringWithFormat("description%ld", code),
20 value: "Sketch could not complete the operation because an unknown error occurred.",
21 table: "SKTError")
22 localizedFailureReason = mainBundle.localizedStringForKey(NSString.stringWithFormat("failureReason%ld", code),
23 value: "An unknown error occurred.",
24 table: "SKTError")
25 errorUserInfo = {NSLocalizedDescriptionKey => localizedDescription,
26 NSLocalizedFailureReasonErrorKey => localizedFailureReason}
27
28 # In Sketch we know that no one's going to be paying attention to the domain
29 # and code that we use here, but still we don't specify junk values.
30 # Certainly we don't just use NSCocoaErrorDomain and some random error code.
31 return NSError.errorWithDomain(SKTErrorDomain, code: code, userInfo: errorUserInfo)
32 end
33
34
35 =begin
36
37 Derived from Apple's sample code for Sketch and converted to MacRuby by Dave Baldwin.
38
39 Additional comments from corresponding header file:
40
41 None.
42
43
44 ---------------------------------------------------------------------------------------------
45 Apple's original notice:
46
47 /*
48 IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. ("Apple") in
49 consideration of your agreement to the following terms, and your use, installation,
50 modification or redistribution of this Apple software constitutes acceptance of these
51 terms. If you do not agree with these terms, please do not use, install, modify or
52 redistribute this Apple software.
53
54 In consideration of your agreement to abide by the following terms, and subject to these
55 terms, Apple grants you a personal, non-exclusive license, under Apple's copyrights in
56 this original Apple software (the "Apple Software"), to use, reproduce, modify and
57 redistribute the Apple Software, with or without modifications, in source and/or binary
58 forms; provided that if you redistribute the Apple Software in its entirety and without
59 modifications, you must retain this notice and the following text and disclaimers in all
60 such redistributions of the Apple Software. Neither the name, trademarks, service marks
61 or logos of Apple Computer, Inc. may be used to endorse or promote products derived from
62 the Apple Software without specific prior written permission from Apple. Except as expressly
63 stated in this notice, no other rights or licenses, express or implied, are granted by Apple
64 herein, including but not limited to any patent rights that may be infringed by your
65 derivative works or by other works in which the Apple Software may be incorporated.
66
67 The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES,
68 EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT,
69 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS
70 USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
71
72 IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL
73 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
74 OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE,
75 REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND
76 WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR
77 OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
78 */
79
80 =end
Something went wrong with that request. Please try again.