From e095510c1009e8e7d47b88b8c8ec01234dbfd164 Mon Sep 17 00:00:00 2001 From: Wojciech Nagrodzki <278594+wnagrodzki@users.noreply.github.com> Date: Sat, 22 Sep 2012 17:49:21 +0200 Subject: [PATCH] Add INErrors --- iNapi.xcodeproj/project.pbxproj | 6 ++++++ iNapi/Classes/Helpers/INErrors.h | 15 +++++++++++++++ iNapi/Classes/Helpers/INErrors.m | 11 +++++++++++ iNapi/Classes/Helpers/INSubtitleDownloader.m | 3 ++- iNapi/Classes/Models/INDownloadResult.m | 3 ++- 5 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 iNapi/Classes/Helpers/INErrors.h create mode 100644 iNapi/Classes/Helpers/INErrors.m diff --git a/iNapi.xcodeproj/project.pbxproj b/iNapi.xcodeproj/project.pbxproj index b2c7d11..b3f4e39 100644 --- a/iNapi.xcodeproj/project.pbxproj +++ b/iNapi.xcodeproj/project.pbxproj @@ -32,6 +32,7 @@ 2E577CDC14F95F6100914F56 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2E577CD214F95F6100914F56 /* MainMenu.xib */; }; 2E577CE414F9620800914F56 /* INPPreferencesWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2E577CE314F9620800914F56 /* INPPreferencesWindowController.m */; }; 2E577CE614F9631000914F56 /* INPPreferencesWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2E577CE514F9631000914F56 /* INPPreferencesWindow.xib */; }; + 2E9CB113160E13C1004D7AAD /* INErrors.m in Sources */ = {isa = PBXBuildFile; fileRef = 2E9CB112160E13C1004D7AAD /* INErrors.m */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -97,6 +98,8 @@ 2E577CE214F9620800914F56 /* INPPreferencesWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = INPPreferencesWindowController.h; sourceTree = ""; }; 2E577CE314F9620800914F56 /* INPPreferencesWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = INPPreferencesWindowController.m; sourceTree = ""; }; 2E577CE514F9631000914F56 /* INPPreferencesWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = INPPreferencesWindow.xib; sourceTree = ""; }; + 2E9CB111160E13C1004D7AAD /* INErrors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = INErrors.h; sourceTree = ""; }; + 2E9CB112160E13C1004D7AAD /* INErrors.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = INErrors.m; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -264,6 +267,8 @@ 2E30A1F31502872E00119004 /* INPMovieFilter.m */, 2E4847561593D23B00D1EBF4 /* INSubtitleDownloader.h */, 2E4847571593D23B00D1EBF4 /* INSubtitleDownloader.m */, + 2E9CB111160E13C1004D7AAD /* INErrors.h */, + 2E9CB112160E13C1004D7AAD /* INErrors.m */, ); path = Helpers; sourceTree = ""; @@ -434,6 +439,7 @@ 2E30A1F41502872E00119004 /* INPMovieFilter.m in Sources */, 2E4847581593D23B00D1EBF4 /* INSubtitleDownloader.m in Sources */, 2E4606B415A4B6CF009C6878 /* INDownloadResult.m in Sources */, + 2E9CB113160E13C1004D7AAD /* INErrors.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/iNapi/Classes/Helpers/INErrors.h b/iNapi/Classes/Helpers/INErrors.h new file mode 100644 index 0000000..42f5d49 --- /dev/null +++ b/iNapi/Classes/Helpers/INErrors.h @@ -0,0 +1,15 @@ +// +// INErrors.h +// iNapi +// +// Created by Wojciech Nagrodzki on 22/09/2012. +// Copyright (c) 2012 Trifork. All rights reserved. +// + +#import + +extern NSString * const iNapiErrorDomain; + +enum { + iNapiSubtitlesNotFound = 1000, +}; \ No newline at end of file diff --git a/iNapi/Classes/Helpers/INErrors.m b/iNapi/Classes/Helpers/INErrors.m new file mode 100644 index 0000000..b2e8150 --- /dev/null +++ b/iNapi/Classes/Helpers/INErrors.m @@ -0,0 +1,11 @@ +// +// INErrors.m +// iNapi +// +// Created by Wojciech Nagrodzki on 22/09/2012. +// Copyright (c) 2012 Trifork. All rights reserved. +// + +#import "INErrors.h" + +NSString * const iNapiErrorDomain = @"com.izydor86.iNapi"; diff --git a/iNapi/Classes/Helpers/INSubtitleDownloader.m b/iNapi/Classes/Helpers/INSubtitleDownloader.m index 8cfcb14..28e09fa 100644 --- a/iNapi/Classes/Helpers/INSubtitleDownloader.m +++ b/iNapi/Classes/Helpers/INSubtitleDownloader.m @@ -7,6 +7,7 @@ // #import "INSubtitleDownloader.h" +#import "INErrors.h" @interface INSubtitleDownloader () @@ -66,7 +67,7 @@ // check if subtitles were found, if not pass error if ([subtitles isEqualToString:@"NPc0"]) { - error = [NSError errorWithDomain:@"com.izydor86.iNapi" code:404 userInfo:nil]; + error = [NSError errorWithDomain:iNapiErrorDomain code:iNapiSubtitlesNotFound userInfo:nil]; dispatch_async(dispatch_get_main_queue(), ^{ completionHandler(nil, error); }); diff --git a/iNapi/Classes/Models/INDownloadResult.m b/iNapi/Classes/Models/INDownloadResult.m index 87173e3..949009c 100644 --- a/iNapi/Classes/Models/INDownloadResult.m +++ b/iNapi/Classes/Models/INDownloadResult.m @@ -7,6 +7,7 @@ // #import "INDownloadResult.h" +#import "INErrors.h" @interface INDownloadResult () @@ -30,7 +31,7 @@ return self; } - if ([error.domain isEqualToString:@"com.izydor86.iNapi"] && error.code == 404) { + if ([error.domain isEqualToString:iNapiErrorDomain] && error.code == iNapiSubtitlesNotFound) { _downloadResultImage = [NSImage imageNamed:@"DownloadStatusNotFound"]; return self; }