1 // Copyright 2022-present 650 Industries. All rights reserved.
2 
3 /**
4  A group of the most common exceptions that might be necessary for modules.
5  */
6 public struct Exceptions {
7   /**
8    The Expo app context is no longer available.
9    */
10   public final class AppContextLost: Exception {
11     override public var reason: String {
12       "The app context has been lost"
13     }
14   }
15 
16   /**
17    The JavaScript runtime is no longer available.
18    */
19   public final class RuntimeLost: Exception {
20     override public var reason: String {
21       "The JavaScript runtime has been lost"
22     }
23   }
24 
25   /**
26    An exception to throw when the operation is not supported on the simulator.
27    */
28   public final class SimulatorNotSupported: Exception {
29     override public var reason: String {
30       "This operation is not supported on the simulator"
31     }
32   }
33 
34   /**
35    An exception to throw when the view with the given tag and class cannot be found.
36    */
37   public final class ViewNotFound<ViewType: UIView>: GenericException<(tag: Int, type: ViewType.Type)> {
38     override public var reason: String {
39       "Unable to find the '\(param.type)' view with tag '\(param.tag)'"
40     }
41   }
42 
43   /**
44    An exception to throw when there is no module implementing the `EXFileSystemInterface` interface.
45    */
46   public final class FileSystemModuleNotFound: Exception {
47     override public var reason: String {
48       "FileSystem module not found, make sure 'expo-file-system' is linked correctly"
49     }
50   }
51 
52   /**
53    An exception to throw when there is no module implementing the `EXPermissionsInterface` interface.
54    - Note: This should never happen since the module is a part of `expo-modules-core`, but for compatibility reasons
55    `appContext.permissions` is still an optional value.
56    */
57   public final class PermissionsModuleNotFound: Exception {
58     override public var reason: String {
59       "Permissions module not found"
60     }
61   }
62 }
63