error.h 5.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #pragma once
  2. #ifdef __cplusplus
  3. extern "C" {
  4. #endif
  5. enum
  6. {
  7. NErr_Success = 0,
  8. NErr_True = 0,
  9. NErr_Error = 1, // generic error
  10. NErr_OutOfMemory = 2,
  11. NErr_FileNotFound = 3,
  12. NErr_NullPointer = 4,
  13. NErr_NotImplemented = 5,// I'm a lazy programmer
  14. NErr_EndOfFile = 6, // also used for "end of enumeration"
  15. NErr_NeedMoreData = 7, // input buffer was too small to provide useful output. Use this instead of NErr_ReadTruncated when it is expected that the caller can call the function again with more data
  16. NErr_False = 8, // returned from a bool-like function to indicate "false" as opposed to "i had an error while figuring it out"
  17. NErr_FailedCreate = 9, // Object could not be created
  18. NErr_Closed = 10,
  19. NErr_TryAgain = 11, // often used in round-robin "isMine()" loops to indicate that you'll take it if no one else wants it first. can also be used for device I/O when the device is busy
  20. NErr_NoDevice = 12,
  21. NErr_UnsupportedFormat = 13,
  22. NErr_Unknown = 14, // NOT meant to be "some unknown error". Usually returned when some passed in enumeration or keyword was an unknown, unexpected or unsupported value
  23. NErr_Insufficient = 15, // output buffer was too small
  24. NErr_Empty = 16,
  25. NErr_LostSynchronization = 17,
  26. NErr_TimedOut = 19,
  27. NErr_BadParameter = 20,
  28. NErr_NoAction = 21, // Returned when no action performed, for example when initializing but something has already been initialized
  29. // Test case related values
  30. NErr_TestFailed = 18, // Result on a test failure, typically used by unit tests and other test cases.
  31. NErr_TestPassed = 0, // Result on a test success, typically used by unit tests and other test cases.
  32. NErr_TestError = 1, // Result on a test error, typically used by unit tests and other test cases.
  33. NErr_TestNotComplete = 22, // Result on a premature stop, typically used by unit tests and other test cases. This is to protect against a scenerio where a test case is in a 'PASSED' state up to a certain point but cannot finish execution due to data missing, environmental issues, etc.
  34. NErr_Malformed = 23, // some peice of data was malformed or had unexpected value (typically returned by parsers)
  35. NErr_WrongFormat = 24, // data was understood but is indicating a different format than expected. e.g. an layer 2 header being encountered by a layer 3 parser
  36. NErr_Reserved = 25, // typically returned when a parser encounters data with a reserved flag set to true
  37. NErr_Changed = 26, // something changed. e.g. samplerate changed mid-stream
  38. NErr_Interrupted = 27,
  39. NErr_ConnectionFailed = 28, // generic "can't connect" error
  40. NErr_DNS = 29, // no DNS entry for the host
  41. /* the follow map NError codes to HTTP error codes. but they can be used for other purposes, too */
  42. NErr_BadRequest = 30, // aka HTTP 400
  43. NErr_Unauthorized = 31, // aka HTTP 401
  44. NErr_Forbidden = 32, // aka HTTP 403
  45. NErr_NotFound = 33, // aka HTTP 404, differentiated from NErr_FileNotFound
  46. NErr_BadMethod = 34, // aka HTTP 405
  47. NErr_NotAcceptable = 35, // aka HTTP 406
  48. NErr_ProxyAuthenticationRequired = 36, // aka HTTP 407
  49. NErr_RequestTimeout = 37, // aka HTTP 408
  50. NErr_Conflict = 38, // aka HTTP 409
  51. NErr_Gone = 39, // aka HTTP 410
  52. NErr_InternalServerError = 40, // aka HTTP 500
  53. NErr_ServiceUnavailable = 41, // aka HTTP 503
  54. NErr_Exception = 42, // Underlying library returns an error or exception that wasn't understood
  55. NErr_Underrun = 43, // Asynchronous thread not supplying data fast enough, buffer has insufficient data
  56. NErr_NoMatchingImplementation = 44, // Returned when a function that delegates functionality to a matching component is unable to find one e.g. api_playlistmanager::Load
  57. NErr_IntegerOverflow = 45,
  58. NErr_IncompatibleVersion = 46, // returned e.g. when a "size" field in a passed struct was larger than expected, or when a flag was set that's not understood
  59. NErr_Disabled = 47,
  60. NErr_ParameterOutOfRange = 48, // Used to signify that a paramater was passed in that is out of bounds for valid values.
  61. NErr_OSNotSupported = 49, // something is not supported on this OS (e.g. WASAPI audio on Windows XP)
  62. NErr_UnsupportedInterface = 50, // used for some APIs (notably svc_decode). It means that you can provide the requested functionality for the provided data (e.g. filename) but don't support the requested interface
  63. NErr_DirectPointer = 51,
  64. NErr_ReadOnly = 52,
  65. NErr_EndOfEnumeration = NErr_EndOfFile, // we'll eventually make this its own number
  66. NErr_ReadTruncated = 54, // somewhat similar to NErr_NeedMoreData. Meant to be used e.g. when a file or input buffer is shorter than expected. Use this instead of NErr_NeedMoreData when the caller cannot provide more data.
  67. NErr_Aborted = 55,
  68. NErr_BadReturnValue = 56, // e.g. a callback function returns an unexpected value
  69. NErr_MaximumDepth = 57,
  70. NErr_Stopped = 58,
  71. NErr_LengthRequired = 59, // aka HTTP 411
  72. NErr_PreconditionFailed = 60, // aka HTTP 411
  73. NErr_TooLarge = 61, // aka HTTP 413
  74. };
  75. typedef int NError;
  76. typedef int ns_error_t; // TODO: eventually make this the name of the enum
  77. #ifdef __cplusplus
  78. }
  79. #endif
  80. // be careful. only use this if your stack variables self-destruct
  81. #define NSERROR_RETURN_ON_FAILURE(x) { int local_ret = x; if (local_ret != NErr_Success) return local_ret; }