{"modulePath":"github.com/opencloud-eu/opencloud","version":"v1.1.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package errorcode\n\nPackage errorcode allows to deal with graph error codes\n\n## Functions\n\n```go\nfunc FromCS3Status(status *cs3rpc.Status, inerr error, ignore ...cs3rpc.Code) error\n```\nFromCS3Status converts a CS3 status code and an error into a corresponding local Error representation.\n\nIt takes a  \\*cs3rpc.Status, an error, and a variadic parameter of type cs3rpc.Code. If the error is not nil, it creates an Error object with the error message and a GeneralException code. If the error is nil, it evaluates the provided CS3 status code and returns an equivalent graph Error. If the CS3 status code does not have a direct equivalent within the app, or is ignored, a general purpose Error is returned.\n\nThis function is particularly useful when dealing with CS3 responses, and a unified error handling within the application is necessary.\n\n```go\nfunc FromStat(stat *provider.StatResponse, err error, ignore ...cs3rpc.Code) error\n```\nFromStat transforms a \\*provider.StatResponse object and an error into an Error.\n\nIt takes a stat of type \\*provider.StatResponse, an error, and a variadic parameter of type cs3rpc.Code. It invokes the FromCS3Status function with the StatResponse Status and the ignore codes.\n\n```go\nfunc FromUtilsStatusCodeError(err error, ignore ...cs3rpc.Code) error\n```\nFromUtilsStatusCodeError returns original error if \\`err\\` does not match to the statusCodeError type\n\n```go\nfunc RenderError(w http.ResponseWriter, r *http.Request, err error)\n```\nRenderError render the Graph Error based on a code or default one\n\n## Types\n\n```go\ntype Error struct {\n\t// contains filtered or unexported fields\n}\n```\nError defines a custom error struct, containing and MS Graph error code and a textual error message\n\n```go\nfunc New(e ErrorCode, msg string) Error\n```\nNew constructs a new errorcode.Error\n\n```go\nfunc ToError(err error) (Error, bool)\n```\nToError checks if the error is of type Error and returns it, the second parameter indicates if the error conversion was successful\n\n```go\nfunc (e Error) Error() string\n```\nError returns the concatenation of the error string and optional message\n\n```go\nfunc (e Error) GetCode() ErrorCode\n```\n\n```go\nfunc (e Error) GetOrigin() ErrorOrigin\n```\nGetOrigin returns the source of the error\n\n```go\nfunc (e Error) Render(w http.ResponseWriter, r *http.Request)\n```\nRender writes a Graph Error object to the response writer\n\n```go\nfunc (e Error) WithOrigin(o ErrorOrigin) Error\n```\nWithOrigin returns a new Error with the provided origin\n\n```go\ntype ErrorCode int\n```\nErrorCode defines code as used in MS Graph - see [https://docs.microsoft.com/en-us/graph/errors?context=graph%2Fapi%2F1.0\u0026view=graph-rest-1.0](https://docs.microsoft.com/en-us/graph/errors?context=graph%2Fapi%2F1.0\u0026view=graph-rest-1.0)\n\n```go\nconst (\n\t// AccessDenied defines the error if the caller doesn't have permission to perform the action.\n\tAccessDenied ErrorCode = iota\n\t// ActivityLimitReached defines the error if the app or user has been throttled.\n\tActivityLimitReached\n\t// GeneralException defines the error if an unspecified error has occurred.\n\tGeneralException\n\t// InvalidAuthenticationToken defines the error if the access token is missing\n\tInvalidAuthenticationToken\n\t// InvalidRange defines the error if the specified byte range is invalid or unavailable.\n\tInvalidRange\n\t// InvalidRequest defines the error if the request is malformed or incorrect.\n\tInvalidRequest\n\t// ItemNotFound defines the error if the resource could not be found.\n\tItemNotFound\n\t// MalwareDetected defines the error if malware was detected in the requested resource.\n\tMalwareDetected\n\t// NameAlreadyExists defines the error if the specified item name already exists.\n\tNameAlreadyExists\n\t// NotAllowed defines the error if the action is not allowed by the system.\n\tNotAllowed\n\t// NotSupported defines the error if the request is not supported by the system.\n\tNotSupported\n\t// ResourceModified defines the error if the resource being updated has changed since the caller last read it, usually an eTag mismatch.\n\tResourceModified\n\t// ResyncRequired defines the error if the delta token is no longer valid, and the app must reset the sync state.\n\tResyncRequired\n\t// ServiceNotAvailable defines the error if the service is not available. Try the request again after a delay. There may be a Retry-After header.\n\tServiceNotAvailable\n\t// SyncStateNotFound defines the error when the sync state generation is not found. The delta token is expired and data must be synchronized again.\n\tSyncStateNotFound\n\t// QuotaLimitReached the user has reached their quota limit.\n\tQuotaLimitReached\n\t// Unauthenticated the caller is not authenticated.\n\tUnauthenticated\n\t// PreconditionFailed the request cannot be made and this error response is sent back\n\tPreconditionFailed\n\t// ItemIsLocked The item is locked by another process. Try again later.\n\tItemIsLocked\n)\n```\nList taken from [https://github.com/microsoft/microsoft-graph-docs-1/blob/main/concepts/errors.md#code-property](https://github.com/microsoft/microsoft-graph-docs-1/blob/main/concepts/errors.md#code-property)\n\n```go\nfunc (e ErrorCode) CreateOdataError(ctx context.Context, msg string) *libregraph.OdataError\n```\nCreateOdataError creates and populates a Graph ErrorCode object\n\n```go\nfunc (e ErrorCode) Render(w http.ResponseWriter, r *http.Request, status int, msg string)\n```\nRender writes a Graph ErrorCode object to the response writer\n\n```go\nfunc (e ErrorCode) String() string\n```\nString returns the string corresponding to the ErrorCode\n\n```go\ntype ErrorOrigin int\n```\nErrorOrigin gives information about where the error originated\n\n```go\nconst (\n\t// ErrorOriginUnknown is the default error source\n\t// and indicates that the error does not have any information about its origin\n\tErrorOriginUnknown ErrorOrigin = iota\n\n\t// ErrorOriginCS3 indicates that the error originated from a CS3 service\n\tErrorOriginCS3\n)\n```\n\n","path":"github.com/opencloud-eu/opencloud/services/graph/pkg/errorcode","name":"errorcode","synopsis":"Package errorcode allows to deal with graph error codes","isRedistributable":true}
