Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / ndp / fx / src / DataWeb / Client / System / Data / Services / Client / Error.cs / 1 / Error.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // //// static error utility functions // //--------------------------------------------------------------------- namespace System.Data.Services.Client { using System; using System.Net; ////// Strongly-typed and parameterized exception factory. /// internal static partial class Error { ////// create and trace new ArgumentException /// /// exception message /// parameter name in error ///ArgumentException internal static ArgumentException Argument(string message, string parameterName) { return Trace(new ArgumentException(message, parameterName)); } ////// create and trace new InvalidOperationException /// /// exception message ///InvalidOperationException internal static InvalidOperationException InvalidOperation(string message) { return Trace(new InvalidOperationException(message)); } ////// create and trace new InvalidOperationException /// /// exception message /// innerException ///InvalidOperationException internal static InvalidOperationException InvalidOperation(string message, Exception innerException) { return Trace(new InvalidOperationException(message, innerException)); } ////// Create and trace a NotSupportedException with a message /// /// Message for the exception ///NotSupportedException internal static NotSupportedException NotSupported(string message) { return Trace(new NotSupportedException(message)); } ////// create and throw a ThrowObjectDisposed with a type name /// /// type being thrown on internal static void ThrowObjectDisposed(Type type) { throw Trace(new ObjectDisposedException(type.ToString())); } ////// create and trace a /// /// errorCode /// message ///InvalidOperationException [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801", Justification = "errorCode ignored for code sharing")] internal static InvalidOperationException HttpHeaderFailure(int errorCode, string message) { return Trace(new InvalidOperationException(message)); } ///create exception when missing an expected batch boundary ///exception to throw internal static InvalidOperationException BatchStreamMissingBoundary() { return InvalidOperation(Strings.BatchStream_MissingBoundary); } ///create exception when the expected content is missing /// http method operation ///exception to throw internal static InvalidOperationException BatchStreamContentExpected(BatchStreamState state) { return InvalidOperation(Strings.BatchStream_ContentExpected(state.ToString())); } ///create exception when unexpected content is discovered /// http method operation ///exception to throw internal static InvalidOperationException BatchStreamContentUnexpected(BatchStreamState state) { return InvalidOperation(Strings.BatchStream_ContentUnexpected(state.ToString())); } ///create exception when Get operation is specified in changeset ///exception to throw internal static InvalidOperationException BatchStreamGetMethodNotSupportInChangeset() { return InvalidOperation(Strings.BatchStream_GetMethodNotSupportedInChangeset); } ///create exception when invalid batch request is specified ///exception to throw internal static InvalidOperationException BatchStreamInvalidBatchFormat() { return InvalidOperation(Strings.BatchStream_InvalidBatchFormat); } ///create exception when boundary delimiter is not valid /// boundary delimiter ///exception to throw internal static InvalidOperationException BatchStreamInvalidDelimiter(string delimiter) { return InvalidOperation(Strings.BatchStream_InvalidDelimiter(delimiter)); } ///create exception when end changeset boundary delimiter is missing ///exception to throw internal static InvalidOperationException BatchStreamMissingEndChangesetDelimiter() { return InvalidOperation(Strings.BatchStream_MissingEndChangesetDelimiter); } ///create exception when header value specified is not valid /// headerValue ///exception to throw internal static InvalidOperationException BatchStreamInvalidHeaderValueSpecified(string headerValue) { return InvalidOperation(Strings.BatchStream_InvalidHeaderValueSpecified(headerValue)); } ///create exception when content length is not valid /// contentLength ///exception to throw internal static InvalidOperationException BatchStreamInvalidContentLengthSpecified(string contentLength) { return InvalidOperation(Strings.BatchStream_InvalidContentLengthSpecified(contentLength)); } ///create exception when CUD operation is specified in batch ///exception to throw internal static InvalidOperationException BatchStreamOnlyGETOperationsCanBeSpecifiedInBatch() { return InvalidOperation(Strings.BatchStream_OnlyGETOperationsCanBeSpecifiedInBatch); } ///create exception when operation header is specified in start of changeset ///exception to throw internal static InvalidOperationException BatchStreamInvalidOperationHeaderSpecified() { return InvalidOperation(Strings.BatchStream_InvalidOperationHeaderSpecified); } ///create exception when http method name is not valid /// methodName ///exception to throw internal static InvalidOperationException BatchStreamInvalidHttpMethodName(string methodName) { return InvalidOperation(Strings.BatchStream_InvalidHttpMethodName(methodName)); } ///create exception when more data is specified after end of batch delimiter. ///exception to throw internal static InvalidOperationException BatchStreamMoreDataAfterEndOfBatch() { return InvalidOperation(Strings.BatchStream_MoreDataAfterEndOfBatch); } ///internal error where batch stream does do look ahead when read request is smaller than boundary delimiter ///exception to throw internal static InvalidOperationException BatchStreamInternalBufferRequestTooSmall() { return InvalidOperation(Strings.BatchStream_InternalBufferRequestTooSmall); } ///method not supported /// method ///exception to throw internal static NotSupportedException MethodNotSupported(System.Linq.Expressions.MethodCallExpression m) { return Error.NotSupported(Strings.ALinq_MethodNotSupported(m.Method.Name)); } ///throw an exception because unexpected batch content was encounted /// internal error internal static void ThrowBatchUnexpectedContent(InternalError value) { throw InvalidOperation(Strings.Batch_UnexpectedContent((int)value)); } ///throw an exception because expected batch content was not encountered /// internal error internal static void ThrowBatchExpectedResponse(InternalError value) { throw InvalidOperation(Strings.Batch_ExpectedResponse((int)value)); } ///internal error where the first request header is not of the form: 'MethodName' 'Url' 'Version' /// actual header value specified in the payload. ///exception to throw internal static InvalidOperationException BatchStreamInvalidMethodHeaderSpecified(string header) { return InvalidOperation(Strings.BatchStream_InvalidMethodHeaderSpecified(header)); } ///internal error when http version in batching request is not valid /// actual version as specified in the payload. /// expected version value. ///exception to throw internal static InvalidOperationException BatchStreamInvalidHttpVersionSpecified(string actualVersion, string expectedVersion) { return InvalidOperation(Strings.BatchStream_InvalidHttpVersionSpecified(actualVersion, expectedVersion)); } ///internal error when number of headers at the start of each operation is not 2 /// valid header name /// valid header name ///exception to throw internal static InvalidOperationException BatchStreamInvalidNumberOfHeadersAtOperationStart(string header1, string header2) { return InvalidOperation(Strings.BatchStream_InvalidNumberOfHeadersAtOperationStart(header1, header2)); } ///internal error Content-Transfer-Encoding is not specified or its value is not 'binary' /// name of the header /// expected value of the header ///exception to throw internal static InvalidOperationException BatchStreamMissingOrInvalidContentEncodingHeader(string headerName, string headerValue) { return InvalidOperation(Strings.BatchStream_MissingOrInvalidContentEncodingHeader(headerName, headerValue)); } ///internal error number of headers at the start of changeset is not correct /// valid header name /// valid header name ///exception to throw internal static InvalidOperationException BatchStreamInvalidNumberOfHeadersAtChangeSetStart(string header1, string header2) { return InvalidOperation(Strings.BatchStream_InvalidNumberOfHeadersAtChangeSetStart(header1, header2)); } ///internal error when content type header is missing /// name of the missing header ///exception to throw internal static InvalidOperationException BatchStreamMissingContentTypeHeader(string headerName) { return InvalidOperation(Strings.BatchStream_MissingContentTypeHeader(headerName)); } ///internal error when content type header value is invalid. /// name of the header whose value is not correct. /// actual value as specified in the payload /// expected value 1 /// expected value 2 ///exception to throw internal static InvalidOperationException BatchStreamInvalidContentTypeSpecified(string headerName, string headerValue, string mime1, string mime2) { return InvalidOperation(Strings.BatchStream_InvalidContentTypeSpecified(headerName, headerValue, mime1, mime2)); } ///unexpected xml when reading web responses /// internal error ///exception to throw internal static InvalidOperationException InternalError(InternalError value) { return InvalidOperation(Strings.Context_InternalError((int)value)); } ///throw exception for unexpected xml when reading web responses /// internal error internal static void ThrowInternalError(InternalError value) { throw InternalError(value); } ////// Trace the exception /// ///type of the exception /// exception object to trace ///the exception parameter private static T Trace(T exception) where T : Exception { return exception; } } /// unique numbers for repeated error messages for unlikely, unactionable exceptions internal enum InternalError { UnexpectedXmlNodeTypeWhenReading = 1, UnexpectedXmlNodeTypeWhenSkipping = 2, UnexpectedEndWhenSkipping = 3, UnexpectedReadState = 4, UnexpectedRequestBufferSizeTooSmall = 5, UnvalidatedEntityState = 6, NullResponseStream = 7, EntityNotDeleted = 8, EntityNotAddedState = 9, LinkNotAddedState = 10, EntryNotModified = 11, LinkBadState = 12, UnexpectedBeginChangeSet = 13, UnexpectedBatchState = 14, ChangeResponseMissingContentID = 15, ChangeResponseUnknownContentID = 16, TooManyBatchResponse = 17, InvalidEndGetRequestStream = 20, InvalidEndGetRequestCompleted = 21, InvalidEndGetRequestStreamRequest = 22, InvalidEndGetRequestStreamStream = 23, InvalidEndGetRequestStreamContent = 24, InvalidEndGetRequestStreamContentLength = 25, InvalidEndWrite = 30, InvalidEndWriteCompleted = 31, InvalidEndWriteRequest = 32, InvalidEndWriteStream = 33, InvalidEndGetResponse = 40, InvalidEndGetResponseCompleted = 41, InvalidEndGetResponseRequest = 42, InvalidEndGetResponseResponse = 43, InvalidAsyncResponseStreamCopy = 44, InvalidAsyncResponseStreamCopyBuffer = 45, InvalidEndRead = 50, InvalidEndReadCompleted = 51, InvalidEndReadStream = 52, InvalidEndReadCopy = 53, InvalidEndReadBuffer = 54, InvalidSaveNextChange = 60, InvalidBeginNextChange = 61, SaveNextChangeIncomplete = 62, InvalidGetRequestStream = 70, InvalidGetResponse = 71, } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // //// static error utility functions // //--------------------------------------------------------------------- namespace System.Data.Services.Client { using System; using System.Net; ////// Strongly-typed and parameterized exception factory. /// internal static partial class Error { ////// create and trace new ArgumentException /// /// exception message /// parameter name in error ///ArgumentException internal static ArgumentException Argument(string message, string parameterName) { return Trace(new ArgumentException(message, parameterName)); } ////// create and trace new InvalidOperationException /// /// exception message ///InvalidOperationException internal static InvalidOperationException InvalidOperation(string message) { return Trace(new InvalidOperationException(message)); } ////// create and trace new InvalidOperationException /// /// exception message /// innerException ///InvalidOperationException internal static InvalidOperationException InvalidOperation(string message, Exception innerException) { return Trace(new InvalidOperationException(message, innerException)); } ////// Create and trace a NotSupportedException with a message /// /// Message for the exception ///NotSupportedException internal static NotSupportedException NotSupported(string message) { return Trace(new NotSupportedException(message)); } ////// create and throw a ThrowObjectDisposed with a type name /// /// type being thrown on internal static void ThrowObjectDisposed(Type type) { throw Trace(new ObjectDisposedException(type.ToString())); } ////// create and trace a /// /// errorCode /// message ///InvalidOperationException [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801", Justification = "errorCode ignored for code sharing")] internal static InvalidOperationException HttpHeaderFailure(int errorCode, string message) { return Trace(new InvalidOperationException(message)); } ///create exception when missing an expected batch boundary ///exception to throw internal static InvalidOperationException BatchStreamMissingBoundary() { return InvalidOperation(Strings.BatchStream_MissingBoundary); } ///create exception when the expected content is missing /// http method operation ///exception to throw internal static InvalidOperationException BatchStreamContentExpected(BatchStreamState state) { return InvalidOperation(Strings.BatchStream_ContentExpected(state.ToString())); } ///create exception when unexpected content is discovered /// http method operation ///exception to throw internal static InvalidOperationException BatchStreamContentUnexpected(BatchStreamState state) { return InvalidOperation(Strings.BatchStream_ContentUnexpected(state.ToString())); } ///create exception when Get operation is specified in changeset ///exception to throw internal static InvalidOperationException BatchStreamGetMethodNotSupportInChangeset() { return InvalidOperation(Strings.BatchStream_GetMethodNotSupportedInChangeset); } ///create exception when invalid batch request is specified ///exception to throw internal static InvalidOperationException BatchStreamInvalidBatchFormat() { return InvalidOperation(Strings.BatchStream_InvalidBatchFormat); } ///create exception when boundary delimiter is not valid /// boundary delimiter ///exception to throw internal static InvalidOperationException BatchStreamInvalidDelimiter(string delimiter) { return InvalidOperation(Strings.BatchStream_InvalidDelimiter(delimiter)); } ///create exception when end changeset boundary delimiter is missing ///exception to throw internal static InvalidOperationException BatchStreamMissingEndChangesetDelimiter() { return InvalidOperation(Strings.BatchStream_MissingEndChangesetDelimiter); } ///create exception when header value specified is not valid /// headerValue ///exception to throw internal static InvalidOperationException BatchStreamInvalidHeaderValueSpecified(string headerValue) { return InvalidOperation(Strings.BatchStream_InvalidHeaderValueSpecified(headerValue)); } ///create exception when content length is not valid /// contentLength ///exception to throw internal static InvalidOperationException BatchStreamInvalidContentLengthSpecified(string contentLength) { return InvalidOperation(Strings.BatchStream_InvalidContentLengthSpecified(contentLength)); } ///create exception when CUD operation is specified in batch ///exception to throw internal static InvalidOperationException BatchStreamOnlyGETOperationsCanBeSpecifiedInBatch() { return InvalidOperation(Strings.BatchStream_OnlyGETOperationsCanBeSpecifiedInBatch); } ///create exception when operation header is specified in start of changeset ///exception to throw internal static InvalidOperationException BatchStreamInvalidOperationHeaderSpecified() { return InvalidOperation(Strings.BatchStream_InvalidOperationHeaderSpecified); } ///create exception when http method name is not valid /// methodName ///exception to throw internal static InvalidOperationException BatchStreamInvalidHttpMethodName(string methodName) { return InvalidOperation(Strings.BatchStream_InvalidHttpMethodName(methodName)); } ///create exception when more data is specified after end of batch delimiter. ///exception to throw internal static InvalidOperationException BatchStreamMoreDataAfterEndOfBatch() { return InvalidOperation(Strings.BatchStream_MoreDataAfterEndOfBatch); } ///internal error where batch stream does do look ahead when read request is smaller than boundary delimiter ///exception to throw internal static InvalidOperationException BatchStreamInternalBufferRequestTooSmall() { return InvalidOperation(Strings.BatchStream_InternalBufferRequestTooSmall); } ///method not supported /// method ///exception to throw internal static NotSupportedException MethodNotSupported(System.Linq.Expressions.MethodCallExpression m) { return Error.NotSupported(Strings.ALinq_MethodNotSupported(m.Method.Name)); } ///throw an exception because unexpected batch content was encounted /// internal error internal static void ThrowBatchUnexpectedContent(InternalError value) { throw InvalidOperation(Strings.Batch_UnexpectedContent((int)value)); } ///throw an exception because expected batch content was not encountered /// internal error internal static void ThrowBatchExpectedResponse(InternalError value) { throw InvalidOperation(Strings.Batch_ExpectedResponse((int)value)); } ///internal error where the first request header is not of the form: 'MethodName' 'Url' 'Version' /// actual header value specified in the payload. ///exception to throw internal static InvalidOperationException BatchStreamInvalidMethodHeaderSpecified(string header) { return InvalidOperation(Strings.BatchStream_InvalidMethodHeaderSpecified(header)); } ///internal error when http version in batching request is not valid /// actual version as specified in the payload. /// expected version value. ///exception to throw internal static InvalidOperationException BatchStreamInvalidHttpVersionSpecified(string actualVersion, string expectedVersion) { return InvalidOperation(Strings.BatchStream_InvalidHttpVersionSpecified(actualVersion, expectedVersion)); } ///internal error when number of headers at the start of each operation is not 2 /// valid header name /// valid header name ///exception to throw internal static InvalidOperationException BatchStreamInvalidNumberOfHeadersAtOperationStart(string header1, string header2) { return InvalidOperation(Strings.BatchStream_InvalidNumberOfHeadersAtOperationStart(header1, header2)); } ///internal error Content-Transfer-Encoding is not specified or its value is not 'binary' /// name of the header /// expected value of the header ///exception to throw internal static InvalidOperationException BatchStreamMissingOrInvalidContentEncodingHeader(string headerName, string headerValue) { return InvalidOperation(Strings.BatchStream_MissingOrInvalidContentEncodingHeader(headerName, headerValue)); } ///internal error number of headers at the start of changeset is not correct /// valid header name /// valid header name ///exception to throw internal static InvalidOperationException BatchStreamInvalidNumberOfHeadersAtChangeSetStart(string header1, string header2) { return InvalidOperation(Strings.BatchStream_InvalidNumberOfHeadersAtChangeSetStart(header1, header2)); } ///internal error when content type header is missing /// name of the missing header ///exception to throw internal static InvalidOperationException BatchStreamMissingContentTypeHeader(string headerName) { return InvalidOperation(Strings.BatchStream_MissingContentTypeHeader(headerName)); } ///internal error when content type header value is invalid. /// name of the header whose value is not correct. /// actual value as specified in the payload /// expected value 1 /// expected value 2 ///exception to throw internal static InvalidOperationException BatchStreamInvalidContentTypeSpecified(string headerName, string headerValue, string mime1, string mime2) { return InvalidOperation(Strings.BatchStream_InvalidContentTypeSpecified(headerName, headerValue, mime1, mime2)); } ///unexpected xml when reading web responses /// internal error ///exception to throw internal static InvalidOperationException InternalError(InternalError value) { return InvalidOperation(Strings.Context_InternalError((int)value)); } ///throw exception for unexpected xml when reading web responses /// internal error internal static void ThrowInternalError(InternalError value) { throw InternalError(value); } ////// Trace the exception /// ///type of the exception /// exception object to trace ///the exception parameter private static T Trace(T exception) where T : Exception { return exception; } } /// unique numbers for repeated error messages for unlikely, unactionable exceptions internal enum InternalError { UnexpectedXmlNodeTypeWhenReading = 1, UnexpectedXmlNodeTypeWhenSkipping = 2, UnexpectedEndWhenSkipping = 3, UnexpectedReadState = 4, UnexpectedRequestBufferSizeTooSmall = 5, UnvalidatedEntityState = 6, NullResponseStream = 7, EntityNotDeleted = 8, EntityNotAddedState = 9, LinkNotAddedState = 10, EntryNotModified = 11, LinkBadState = 12, UnexpectedBeginChangeSet = 13, UnexpectedBatchState = 14, ChangeResponseMissingContentID = 15, ChangeResponseUnknownContentID = 16, TooManyBatchResponse = 17, InvalidEndGetRequestStream = 20, InvalidEndGetRequestCompleted = 21, InvalidEndGetRequestStreamRequest = 22, InvalidEndGetRequestStreamStream = 23, InvalidEndGetRequestStreamContent = 24, InvalidEndGetRequestStreamContentLength = 25, InvalidEndWrite = 30, InvalidEndWriteCompleted = 31, InvalidEndWriteRequest = 32, InvalidEndWriteStream = 33, InvalidEndGetResponse = 40, InvalidEndGetResponseCompleted = 41, InvalidEndGetResponseRequest = 42, InvalidEndGetResponseResponse = 43, InvalidAsyncResponseStreamCopy = 44, InvalidAsyncResponseStreamCopyBuffer = 45, InvalidEndRead = 50, InvalidEndReadCompleted = 51, InvalidEndReadStream = 52, InvalidEndReadCopy = 53, InvalidEndReadBuffer = 54, InvalidSaveNextChange = 60, InvalidBeginNextChange = 61, SaveNextChangeIncomplete = 62, InvalidGetRequestStream = 70, InvalidGetResponse = 71, } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- RegexInterpreter.cs
- DocumentSchemaValidator.cs
- HTTP_SERVICE_CONFIG_URLACL_PARAM.cs
- DictionaryBase.cs
- CodeExporter.cs
- InvalidDataException.cs
- ProfileProvider.cs
- SecurityPermission.cs
- WindowsListViewItem.cs
- ListView.cs
- BlobPersonalizationState.cs
- SqlGenerator.cs
- ToolTip.cs
- BuildProviderCollection.cs
- PolyBezierSegmentFigureLogic.cs
- Parameter.cs
- DataGridViewImageCell.cs
- SyndicationSerializer.cs
- EncryptedReference.cs
- ResourceSetExpression.cs
- Size3DConverter.cs
- Win32PrintDialog.cs
- ObjectDataSourceMethodEditor.cs
- TransactedReceiveScope.cs
- FixedSOMPageConstructor.cs
- CharEnumerator.cs
- WindowsRegion.cs
- WhitespaceRuleReader.cs
- Nullable.cs
- WebSysDisplayNameAttribute.cs
- LineInfo.cs
- Panel.cs
- Selection.cs
- CompositeFontFamily.cs
- TerminatorSinks.cs
- TimeEnumHelper.cs
- DataControlFieldHeaderCell.cs
- FileAuthorizationModule.cs
- DataGridViewControlCollection.cs
- ButtonColumn.cs
- UserControl.cs
- PenContexts.cs
- InfoCardRSAPKCS1KeyExchangeFormatter.cs
- SqlErrorCollection.cs
- SignatureHelper.cs
- ServicePoint.cs
- PropertyPathWorker.cs
- DrawingAttributesDefaultValueFactory.cs
- ReachPrintTicketSerializerAsync.cs
- MediaPlayerState.cs
- ConfigurationManagerHelper.cs
- HistoryEventArgs.cs
- SmiEventSink_DeferedProcessing.cs
- ColorTransformHelper.cs
- ListViewGroupItemCollection.cs
- ServiceRouteHandler.cs
- HtmlTextArea.cs
- DetailsViewRow.cs
- XmlCDATASection.cs
- EventRouteFactory.cs
- LinkArea.cs
- OracleBinary.cs
- UpdateCommand.cs
- ElementHostAutomationPeer.cs
- FamilyTypefaceCollection.cs
- WorkflowFileItem.cs
- InvokeWebServiceDesigner.cs
- SQLBytes.cs
- WebServiceResponseDesigner.cs
- CryptoStream.cs
- SimpleFileLog.cs
- MulticastDelegate.cs
- mansign.cs
- WeakReferenceList.cs
- SHA1CryptoServiceProvider.cs
- xmlformatgeneratorstatics.cs
- PagePropertiesChangingEventArgs.cs
- Reference.cs
- GridViewUpdatedEventArgs.cs
- DefaultBindingPropertyAttribute.cs
- Relationship.cs
- TemplateBuilder.cs
- IdnMapping.cs
- Rectangle.cs
- WebHostScriptMappingsInstallComponent.cs
- SiteMapProvider.cs
- PerformanceCounterCategory.cs
- IList.cs
- TextTreeTextBlock.cs
- DBSqlParserColumnCollection.cs
- Stylus.cs
- Symbol.cs
- COM2TypeInfoProcessor.cs
- TabletDevice.cs
- Console.cs
- IndexedGlyphRun.cs
- ByteStack.cs
- ListCommandEventArgs.cs
- XmlArrayItemAttributes.cs
- DataGridTableCollection.cs