1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24
25 #include "pxr/pxr.h"
26 #include "pxr/usd/pcp/errors.h"
27 #include "pxr/base/tf/stringUtils.h"
28
29 PXR_NAMESPACE_OPEN_SCOPE
30
31 ///////////////////////////////////////////////////////////////////////////////
32
TF_REGISTRY_FUNCTION(TfEnum)33 TF_REGISTRY_FUNCTION(TfEnum) {
34 TF_ADD_ENUM_NAME(PcpErrorType_ArcCycle);
35 TF_ADD_ENUM_NAME(PcpErrorType_ArcPermissionDenied);
36 TF_ADD_ENUM_NAME(PcpErrorType_IndexCapacityExceeded);
37 TF_ADD_ENUM_NAME(PcpErrorType_ArcCapacityExceeded);
38 TF_ADD_ENUM_NAME(PcpErrorType_ArcNamespaceDepthCapacityExceeded);
39 TF_ADD_ENUM_NAME(PcpErrorType_InconsistentPropertyType);
40 TF_ADD_ENUM_NAME(PcpErrorType_InconsistentAttributeType);
41 TF_ADD_ENUM_NAME(PcpErrorType_InconsistentAttributeVariability);
42 TF_ADD_ENUM_NAME(PcpErrorType_InternalAssetPath);
43 TF_ADD_ENUM_NAME(PcpErrorType_InvalidPrimPath);
44 TF_ADD_ENUM_NAME(PcpErrorType_InvalidAssetPath);
45 TF_ADD_ENUM_NAME(PcpErrorType_InvalidInstanceTargetPath);
46 TF_ADD_ENUM_NAME(PcpErrorType_InvalidExternalTargetPath);
47 TF_ADD_ENUM_NAME(PcpErrorType_InvalidTargetPath);
48 TF_ADD_ENUM_NAME(PcpErrorType_InvalidReferenceOffset);
49 TF_ADD_ENUM_NAME(PcpErrorType_InvalidSublayerOffset);
50 TF_ADD_ENUM_NAME(PcpErrorType_InvalidSublayerOwnership);
51 TF_ADD_ENUM_NAME(PcpErrorType_InvalidSublayerPath);
52 TF_ADD_ENUM_NAME(PcpErrorType_InvalidVariantSelection);
53 TF_ADD_ENUM_NAME(PcpErrorType_OpinionAtRelocationSource);
54 TF_ADD_ENUM_NAME(PcpErrorType_PrimPermissionDenied);
55 TF_ADD_ENUM_NAME(PcpErrorType_PropertyPermissionDenied);
56 TF_ADD_ENUM_NAME(PcpErrorType_SublayerCycle);
57 TF_ADD_ENUM_NAME(PcpErrorType_TargetPermissionDenied);
58 TF_ADD_ENUM_NAME(PcpErrorType_UnresolvedPrimPath);
59 }
60
61 ///////////////////////////////////////////////////////////////////////////////
62
PcpErrorBase(TfEnum errorType)63 PcpErrorBase::PcpErrorBase(TfEnum errorType) :
64 errorType(errorType)
65 {
66 }
67
68 // virtual
~PcpErrorBase()69 PcpErrorBase::~PcpErrorBase()
70 {
71 }
72
73 ///////////////////////////////////////////////////////////////////////////////
74
75 PcpErrorArcCyclePtr
New()76 PcpErrorArcCycle::New()
77 {
78 return PcpErrorArcCyclePtr(new PcpErrorArcCycle);
79 }
80
PcpErrorArcCycle()81 PcpErrorArcCycle::PcpErrorArcCycle() :
82 PcpErrorBase(PcpErrorType_ArcCycle)
83 {
84 }
85
~PcpErrorArcCycle()86 PcpErrorArcCycle::~PcpErrorArcCycle()
87 {
88 }
89
90 // virtual
91 std::string
ToString() const92 PcpErrorArcCycle::ToString() const
93 {
94 if (cycle.empty())
95 return std::string();
96
97 std::string msg = "Cycle detected:\n";
98 for (size_t i = 0; i < cycle.size(); i++) {
99 const PcpSiteTrackerSegment &segment = cycle[i];
100 if (i > 0) {
101 if (i + 1 < cycle.size()) {
102 switch(segment.arcType) {
103 case PcpArcTypeInherit:
104 msg += "inherits from:\n";
105 break;
106 case PcpArcTypeRelocate:
107 msg += "is relocated from:\n";
108 break;
109 case PcpArcTypeVariant:
110 msg += "uses variant:\n";
111 break;
112 case PcpArcTypeReference:
113 msg += "references:\n";
114 break;
115 case PcpArcTypePayload:
116 msg += "gets payload from:\n";
117 break;
118 default:
119 msg += "refers to:\n";
120 break;
121 }
122 }
123 else {
124 msg += "CANNOT ";
125 switch(segment.arcType) {
126 case PcpArcTypeInherit:
127 msg += "inherit from:\n";
128 break;
129 case PcpArcTypeRelocate:
130 msg += "be relocated from:\n";
131 break;
132 case PcpArcTypeVariant:
133 msg += "use variant:\n";
134 break;
135 case PcpArcTypeReference:
136 msg += "reference:\n";
137 break;
138 case PcpArcTypePayload:
139 msg += "get payload from:\n";
140 break;
141 default:
142 msg += "refer to:\n";
143 break;
144 }
145 }
146 }
147 msg += TfStringPrintf("%s\n", TfStringify(segment.site).c_str());
148 if ((i > 0) && (i + 1 < cycle.size()))
149 msg += "which ";
150 }
151 return msg;
152 }
153
154 ///////////////////////////////////////////////////////////////////////////////
155
156 PcpErrorArcPermissionDeniedPtr
New()157 PcpErrorArcPermissionDenied::New()
158 {
159 return PcpErrorArcPermissionDeniedPtr(new PcpErrorArcPermissionDenied);
160 }
161
PcpErrorArcPermissionDenied()162 PcpErrorArcPermissionDenied::PcpErrorArcPermissionDenied() :
163 PcpErrorBase(PcpErrorType_ArcPermissionDenied)
164 {
165 }
166
~PcpErrorArcPermissionDenied()167 PcpErrorArcPermissionDenied::~PcpErrorArcPermissionDenied()
168 {
169 }
170
171 // virtual
172 std::string
ToString() const173 PcpErrorArcPermissionDenied::ToString() const
174 {
175 std::string msg = TfStringPrintf("%s\nCANNOT ", TfStringify(site).c_str());
176 switch(arcType) {
177 case PcpArcTypeInherit:
178 msg += "inherit from:\n";
179 break;
180 case PcpArcTypeRelocate:
181 msg += "be relocated from:\n";
182 break;
183 case PcpArcTypeVariant:
184 msg += "use variant:\n";
185 break;
186 case PcpArcTypeReference:
187 msg += "reference:\n";
188 break;
189 case PcpArcTypePayload:
190 msg += "get payload from:\n";
191 break;
192 default:
193 msg += "refer to:\n";
194 break;
195 }
196 msg += TfStringPrintf("%s\nwhich is private.",
197 TfStringify(privateSite).c_str());
198 return msg;
199 }
200
201 ///////////////////////////////////////////////////////////////////////////////
202
203 PcpErrorCapacityExceededPtr
New(PcpErrorType errorType)204 PcpErrorCapacityExceeded::New(PcpErrorType errorType)
205 {
206 return PcpErrorCapacityExceededPtr(new PcpErrorCapacityExceeded(errorType));
207 }
208
PcpErrorCapacityExceeded(PcpErrorType errorType)209 PcpErrorCapacityExceeded::PcpErrorCapacityExceeded(PcpErrorType errorType) :
210 PcpErrorBase(errorType)
211 {
212 }
213
~PcpErrorCapacityExceeded()214 PcpErrorCapacityExceeded::~PcpErrorCapacityExceeded()
215 {
216 }
217
218 // virtual
219 std::string
ToString() const220 PcpErrorCapacityExceeded::ToString() const
221 {
222 return std::string("Composition graph capacity exceeded: ") +
223 TfEnum::GetDisplayName(errorType);
224 }
225
226 ///////////////////////////////////////////////////////////////////////////////
227
PcpErrorInconsistentPropertyBase(TfEnum errorType)228 PcpErrorInconsistentPropertyBase::PcpErrorInconsistentPropertyBase(
229 TfEnum errorType) :
230 PcpErrorBase(errorType)
231 {
232 }
233
234 // virtual
~PcpErrorInconsistentPropertyBase()235 PcpErrorInconsistentPropertyBase::~PcpErrorInconsistentPropertyBase()
236 {
237 }
238
239 ///////////////////////////////////////////////////////////////////////////////
240
241 PcpErrorInconsistentPropertyTypePtr
New()242 PcpErrorInconsistentPropertyType::New()
243 {
244 return PcpErrorInconsistentPropertyTypePtr(
245 new PcpErrorInconsistentPropertyType);
246 }
247
PcpErrorInconsistentPropertyType()248 PcpErrorInconsistentPropertyType::PcpErrorInconsistentPropertyType() :
249 PcpErrorInconsistentPropertyBase(PcpErrorType_InconsistentPropertyType)
250 {
251 }
252
~PcpErrorInconsistentPropertyType()253 PcpErrorInconsistentPropertyType::~PcpErrorInconsistentPropertyType()
254 {
255 }
256
257 // virtual
258 std::string
ToString() const259 PcpErrorInconsistentPropertyType::ToString() const
260 {
261 return TfStringPrintf(
262 "The property <%s> has inconsistent spec types. "
263 "The defining spec is @%s@<%s> and is %s spec. "
264 "The conflicting spec is @%s@<%s> and is %s spec. "
265 "The conflicting spec will be ignored.",
266 rootSite.path.GetString().c_str(),
267 definingLayerIdentifier.c_str(),
268 definingSpecPath.GetString().c_str(),
269 (definingSpecType == SdfSpecTypeAttribute ?
270 "an attribute" : "a relationship"),
271 conflictingLayerIdentifier.c_str(),
272 conflictingSpecPath.GetString().c_str(),
273 (conflictingSpecType == SdfSpecTypeAttribute ?
274 "an attribute" : "a relationship"));
275 }
276
277 ///////////////////////////////////////////////////////////////////////////////
278
279 PcpErrorInconsistentAttributeTypePtr
New()280 PcpErrorInconsistentAttributeType::New()
281 {
282 return PcpErrorInconsistentAttributeTypePtr(
283 new PcpErrorInconsistentAttributeType);
284 }
285
PcpErrorInconsistentAttributeType()286 PcpErrorInconsistentAttributeType::PcpErrorInconsistentAttributeType() :
287 PcpErrorInconsistentPropertyBase(PcpErrorType_InconsistentAttributeType)
288 {
289 }
290
~PcpErrorInconsistentAttributeType()291 PcpErrorInconsistentAttributeType::~PcpErrorInconsistentAttributeType()
292 {
293 }
294
295 // virtual
296 std::string
ToString() const297 PcpErrorInconsistentAttributeType::ToString() const
298 {
299 return TfStringPrintf(
300 "The attribute <%s> has specs with inconsistent value types. "
301 "The defining spec is @%s@<%s> with value type '%s'. "
302 "The conflicting spec is @%s@<%s> with value type '%s'. "
303 "The conflicting spec will be ignored.",
304 rootSite.path.GetString().c_str(),
305 definingLayerIdentifier.c_str(),
306 definingSpecPath.GetString().c_str(),
307 definingValueType.GetText(),
308 conflictingLayerIdentifier.c_str(),
309 conflictingSpecPath.GetString().c_str(),
310 conflictingValueType.GetText());
311 }
312
313 ///////////////////////////////////////////////////////////////////////////////
314
315 PcpErrorInconsistentAttributeVariabilityPtr
New()316 PcpErrorInconsistentAttributeVariability::New()
317 {
318 return PcpErrorInconsistentAttributeVariabilityPtr(
319 new PcpErrorInconsistentAttributeVariability);
320 }
321
322 PcpErrorInconsistentAttributeVariability::
PcpErrorInconsistentAttributeVariability()323 PcpErrorInconsistentAttributeVariability() :
324 PcpErrorInconsistentPropertyBase(
325 PcpErrorType_InconsistentAttributeVariability)
326 {
327 }
328
329 PcpErrorInconsistentAttributeVariability::
~PcpErrorInconsistentAttributeVariability()330 ~PcpErrorInconsistentAttributeVariability()
331 {
332 }
333
334 // virtual
335 std::string
ToString() const336 PcpErrorInconsistentAttributeVariability::ToString() const
337 {
338 return TfStringPrintf(
339 "The attribute <%s> has specs with inconsistent variability. "
340 "The defining spec is @%s@<%s> with variability '%s'. The "
341 "conflicting spec is @%s@<%s> with variability '%s'. The "
342 "conflicting variability will be ignored.",
343 rootSite.path.GetString().c_str(),
344 definingLayerIdentifier.c_str(),
345 definingSpecPath.GetString().c_str(),
346 TfEnum::GetName(definingVariability).c_str(),
347 conflictingLayerIdentifier.c_str(),
348 conflictingSpecPath.GetString().c_str(),
349 TfEnum::GetName(conflictingVariability).c_str());
350 }
351
352 ///////////////////////////////////////////////////////////////////////////////
353
354 PcpErrorInternalAssetPathPtr
New()355 PcpErrorInternalAssetPath::New()
356 {
357 return PcpErrorInternalAssetPathPtr(new PcpErrorInternalAssetPath);
358 }
359
PcpErrorInternalAssetPath()360 PcpErrorInternalAssetPath::PcpErrorInternalAssetPath() :
361 PcpErrorBase(PcpErrorType_InternalAssetPath)
362 {
363 }
364
~PcpErrorInternalAssetPath()365 PcpErrorInternalAssetPath::~PcpErrorInternalAssetPath()
366 {
367 }
368
369 // virtual
370 std::string
ToString() const371 PcpErrorInternalAssetPath::ToString() const
372 {
373 return TfStringPrintf("Ignoring %s path on prim <%s> because asset @%s@ "
374 "is internal.",
375 TfEnum::GetDisplayName(arcType).c_str(),
376 site.path.GetText(), resolvedAssetPath.c_str());
377 }
378
379 ///////////////////////////////////////////////////////////////////////////////
380
381 PcpErrorInvalidPrimPathPtr
New()382 PcpErrorInvalidPrimPath::New()
383 {
384 return PcpErrorInvalidPrimPathPtr(new PcpErrorInvalidPrimPath);
385 }
386
PcpErrorInvalidPrimPath()387 PcpErrorInvalidPrimPath::PcpErrorInvalidPrimPath() :
388 PcpErrorBase(PcpErrorType_InvalidPrimPath)
389 {
390 }
391
~PcpErrorInvalidPrimPath()392 PcpErrorInvalidPrimPath::~PcpErrorInvalidPrimPath()
393 {
394 }
395
396 // virtual
397 std::string
ToString() const398 PcpErrorInvalidPrimPath::ToString() const
399 {
400 return TfStringPrintf("Invalid %s path <%s> on prim %s "
401 "-- must be an absolute prim path.",
402 TfEnum::GetDisplayName(arcType).c_str(),
403 primPath.GetText(),
404 TfStringify(site).c_str());
405 }
406
407 ///////////////////////////////////////////////////////////////////////////////
408
PcpErrorInvalidAssetPathBase(TfEnum errorType)409 PcpErrorInvalidAssetPathBase::PcpErrorInvalidAssetPathBase(
410 TfEnum errorType) :
411 PcpErrorBase(errorType)
412 {
413 }
414
415 // virtual
~PcpErrorInvalidAssetPathBase()416 PcpErrorInvalidAssetPathBase::~PcpErrorInvalidAssetPathBase()
417 {
418 }
419
420 ///////////////////////////////////////////////////////////////////////////////
421
422 PcpErrorInvalidAssetPathPtr
New()423 PcpErrorInvalidAssetPath::New()
424 {
425 return PcpErrorInvalidAssetPathPtr(new PcpErrorInvalidAssetPath);
426 }
427
PcpErrorInvalidAssetPath()428 PcpErrorInvalidAssetPath::PcpErrorInvalidAssetPath() :
429 PcpErrorInvalidAssetPathBase(PcpErrorType_InvalidAssetPath)
430 {
431 }
432
~PcpErrorInvalidAssetPath()433 PcpErrorInvalidAssetPath::~PcpErrorInvalidAssetPath()
434 {
435 }
436
437 // virtual
438 std::string
ToString() const439 PcpErrorInvalidAssetPath::ToString() const
440 {
441 return TfStringPrintf("Could not open asset @%s@ for %s on prim %s%s%s.",
442 resolvedAssetPath.c_str(),
443 TfEnum::GetDisplayName(arcType).c_str(),
444 TfStringify(site).c_str(),
445 messages.empty() ? "" : " -- ",
446 messages.c_str());
447 }
448
449 ///////////////////////////////////////////////////////////////////////////////
450
451 PcpErrorMutedAssetPathPtr
New()452 PcpErrorMutedAssetPath::New()
453 {
454 return PcpErrorMutedAssetPathPtr(new PcpErrorMutedAssetPath);
455 }
456
PcpErrorMutedAssetPath()457 PcpErrorMutedAssetPath::PcpErrorMutedAssetPath() :
458 PcpErrorInvalidAssetPathBase(PcpErrorType_MutedAssetPath)
459 {
460 }
461
~PcpErrorMutedAssetPath()462 PcpErrorMutedAssetPath::~PcpErrorMutedAssetPath()
463 {
464 }
465
466 // virtual
467 std::string
ToString() const468 PcpErrorMutedAssetPath::ToString() const
469 {
470 return TfStringPrintf("Asset @%s@ was muted for %s on prim %s.",
471 resolvedAssetPath.c_str(),
472 TfEnum::GetDisplayName(arcType).c_str(),
473 TfStringify(site).c_str());
474 }
475
476 ///////////////////////////////////////////////////////////////////////////////
477
PcpErrorTargetPathBase(TfEnum errorType)478 PcpErrorTargetPathBase::PcpErrorTargetPathBase(TfEnum errorType)
479 : PcpErrorBase(errorType)
480 {
481 }
482
~PcpErrorTargetPathBase()483 PcpErrorTargetPathBase::~PcpErrorTargetPathBase()
484 {
485 }
486
487 ///////////////////////////////////////////////////////////////////////////////
488
489 PcpErrorInvalidInstanceTargetPathPtr
New()490 PcpErrorInvalidInstanceTargetPath::New()
491 {
492 return PcpErrorInvalidInstanceTargetPathPtr(
493 new PcpErrorInvalidInstanceTargetPath);
494 }
495
PcpErrorInvalidInstanceTargetPath()496 PcpErrorInvalidInstanceTargetPath::PcpErrorInvalidInstanceTargetPath()
497 : PcpErrorTargetPathBase(PcpErrorType_InvalidInstanceTargetPath)
498 {
499 }
500
~PcpErrorInvalidInstanceTargetPath()501 PcpErrorInvalidInstanceTargetPath::~PcpErrorInvalidInstanceTargetPath()
502 {
503 }
504
505 // virtual
506 std::string
ToString() const507 PcpErrorInvalidInstanceTargetPath::ToString() const
508 {
509 TF_VERIFY(ownerSpecType == SdfSpecTypeAttribute ||
510 ownerSpecType == SdfSpecTypeRelationship);
511 return TfStringPrintf(
512 "The %s <%s> from <%s> in layer @%s@ is authored in a class "
513 "but refers to an instance of that class. Ignoring.",
514 (ownerSpecType == SdfSpecTypeAttribute
515 ? "attribute connection"
516 : "relationship target"),
517 targetPath.GetText(),
518 owningPath.GetText(),
519 layer->GetIdentifier().c_str());
520 }
521
522 ///////////////////////////////////////////////////////////////////////////////
523
524 PcpErrorInvalidExternalTargetPathPtr
New()525 PcpErrorInvalidExternalTargetPath::New()
526 {
527 return PcpErrorInvalidExternalTargetPathPtr(
528 new PcpErrorInvalidExternalTargetPath);
529 }
530
PcpErrorInvalidExternalTargetPath()531 PcpErrorInvalidExternalTargetPath::PcpErrorInvalidExternalTargetPath()
532 : PcpErrorTargetPathBase(PcpErrorType_InvalidExternalTargetPath)
533 {
534 }
535
~PcpErrorInvalidExternalTargetPath()536 PcpErrorInvalidExternalTargetPath::~PcpErrorInvalidExternalTargetPath()
537 {
538 }
539
540 // virtual
541 std::string
ToString() const542 PcpErrorInvalidExternalTargetPath::ToString() const
543 {
544 TF_VERIFY(ownerSpecType == SdfSpecTypeAttribute ||
545 ownerSpecType == SdfSpecTypeRelationship);
546 return TfStringPrintf("The %s <%s> from <%s> in layer @%s@ refers "
547 "to a path outside the scope of the %s from <%s>. "
548 "Ignoring.",
549 (ownerSpecType == SdfSpecTypeAttribute
550 ? "attribute connection"
551 : "relationship target"),
552 targetPath.GetText(),
553 owningPath.GetText(),
554 layer->GetIdentifier().c_str(),
555 TfEnum::GetDisplayName(TfEnum(ownerArcType)).c_str(),
556 ownerIntroPath.GetText());
557 }
558
559 ///////////////////////////////////////////////////////////////////////////////
560
561 PcpErrorInvalidTargetPathPtr
New()562 PcpErrorInvalidTargetPath::New()
563 {
564 return PcpErrorInvalidTargetPathPtr(
565 new PcpErrorInvalidTargetPath);
566 }
567
PcpErrorInvalidTargetPath()568 PcpErrorInvalidTargetPath::PcpErrorInvalidTargetPath()
569 : PcpErrorTargetPathBase(PcpErrorType_InvalidTargetPath)
570 {
571 }
572
~PcpErrorInvalidTargetPath()573 PcpErrorInvalidTargetPath::~PcpErrorInvalidTargetPath()
574 {
575 }
576
577 // virtual
578 std::string
ToString() const579 PcpErrorInvalidTargetPath::ToString() const
580 {
581 TF_VERIFY(ownerSpecType == SdfSpecTypeAttribute ||
582 ownerSpecType == SdfSpecTypeRelationship);
583 return TfStringPrintf(
584 "The %s <%s> from <%s> in layer @%s@ is invalid. This may be "
585 "because the path is the pre-relocated source path of a "
586 "relocated prim. Ignoring.",
587 (ownerSpecType == SdfSpecTypeAttribute
588 ? "attribute connection"
589 : "relationship target"),
590 targetPath.GetText(),
591 owningPath.GetText(),
592 layer->GetIdentifier().c_str());
593 }
594
595 ///////////////////////////////////////////////////////////////////////////////
596
597 PcpErrorInvalidSublayerOffsetPtr
New()598 PcpErrorInvalidSublayerOffset::New()
599 {
600 return PcpErrorInvalidSublayerOffsetPtr(new PcpErrorInvalidSublayerOffset);
601 }
602
PcpErrorInvalidSublayerOffset()603 PcpErrorInvalidSublayerOffset::PcpErrorInvalidSublayerOffset() :
604 PcpErrorBase(PcpErrorType_InvalidSublayerOffset)
605 {
606 }
607
~PcpErrorInvalidSublayerOffset()608 PcpErrorInvalidSublayerOffset::~PcpErrorInvalidSublayerOffset()
609 {
610 }
611
612 // virtual
613 std::string
ToString() const614 PcpErrorInvalidSublayerOffset::ToString() const
615 {
616 return TfStringPrintf("Invalid sublayer offset %s in sublayer @%s@ of "
617 "layer @%s@. Using no offset instead.",
618 TfStringify(offset).c_str(),
619 sublayer->GetIdentifier().c_str(),
620 layer->GetIdentifier().c_str());
621 }
622
623 ///////////////////////////////////////////////////////////////////////////////
624
625 PcpErrorInvalidReferenceOffsetPtr
New()626 PcpErrorInvalidReferenceOffset::New()
627 {
628 return PcpErrorInvalidReferenceOffsetPtr(new PcpErrorInvalidReferenceOffset);
629 }
630
PcpErrorInvalidReferenceOffset()631 PcpErrorInvalidReferenceOffset::PcpErrorInvalidReferenceOffset() :
632 PcpErrorBase(PcpErrorType_InvalidReferenceOffset)
633 {
634 }
635
~PcpErrorInvalidReferenceOffset()636 PcpErrorInvalidReferenceOffset::~PcpErrorInvalidReferenceOffset()
637 {
638 }
639
640 // virtual
641 std::string
ToString() const642 PcpErrorInvalidReferenceOffset::ToString() const
643 {
644 return TfStringPrintf("Invalid reference offset %s at %s on "
645 "asset path '%s'. Using no offset instead.",
646 TfStringify(offset).c_str(),
647 TfStringify(PcpSite(layer, sourcePath)).c_str(),
648 assetPath.c_str());
649 }
650
651 ///////////////////////////////////////////////////////////////////////////////
652
653 PcpErrorInvalidSublayerOwnershipPtr
New()654 PcpErrorInvalidSublayerOwnership::New()
655 {
656 return PcpErrorInvalidSublayerOwnershipPtr(
657 new PcpErrorInvalidSublayerOwnership);
658 }
659
PcpErrorInvalidSublayerOwnership()660 PcpErrorInvalidSublayerOwnership::PcpErrorInvalidSublayerOwnership() :
661 PcpErrorBase(PcpErrorType_InvalidSublayerOwnership)
662 {
663 }
664
~PcpErrorInvalidSublayerOwnership()665 PcpErrorInvalidSublayerOwnership::~PcpErrorInvalidSublayerOwnership()
666 {
667 }
668
669 // virtual
670 std::string
ToString() const671 PcpErrorInvalidSublayerOwnership::ToString() const
672 {
673 std::vector<std::string> sublayerStrVec;
674 TF_FOR_ALL(sublayer, sublayers) {
675 sublayerStrVec.push_back("@" + (*sublayer)->GetIdentifier() + "@");
676 }
677 return TfStringPrintf("The following sublayers for layer @%s@ have the "
678 "same owner '%s': %s",
679 layer->GetIdentifier().c_str(),
680 owner.c_str(),
681 TfStringJoin(sublayerStrVec, ", ").c_str());
682 }
683
684 ///////////////////////////////////////////////////////////////////////////////
685
686 PcpErrorInvalidSublayerPathPtr
New()687 PcpErrorInvalidSublayerPath::New()
688 {
689 return PcpErrorInvalidSublayerPathPtr(new PcpErrorInvalidSublayerPath);
690 }
691
PcpErrorInvalidSublayerPath()692 PcpErrorInvalidSublayerPath::PcpErrorInvalidSublayerPath() :
693 PcpErrorBase(PcpErrorType_InvalidSublayerPath)
694 {
695 }
696
~PcpErrorInvalidSublayerPath()697 PcpErrorInvalidSublayerPath::~PcpErrorInvalidSublayerPath()
698 {
699 }
700
701 // virtual
702 std::string
ToString() const703 PcpErrorInvalidSublayerPath::ToString() const
704 {
705 return TfStringPrintf("Could not load sublayer @%s@ of layer @%s@%s%s; "
706 "skipping.",
707 sublayerPath.c_str(),
708 layer ? layer->GetIdentifier().c_str()
709 : "<NULL>",
710 messages.empty() ? "" : " -- ",
711 messages.c_str());
712 }
713
714 ///////////////////////////////////////////////////////////////////////////////
715
716 PcpErrorInvalidVariantSelectionPtr
New()717 PcpErrorInvalidVariantSelection::New()
718 {
719 return PcpErrorInvalidVariantSelectionPtr(
720 new PcpErrorInvalidVariantSelection);
721 }
722
PcpErrorInvalidVariantSelection()723 PcpErrorInvalidVariantSelection::PcpErrorInvalidVariantSelection() :
724 PcpErrorBase(PcpErrorType_InvalidVariantSelection)
725 {
726 }
727
~PcpErrorInvalidVariantSelection()728 PcpErrorInvalidVariantSelection::~PcpErrorInvalidVariantSelection()
729 {
730 }
731
732 // virtual
733 std::string
ToString() const734 PcpErrorInvalidVariantSelection::ToString() const
735 {
736 return TfStringPrintf("Invalid variant selection {%s = %s} at <%s> "
737 "in @%s@.",
738 vset.c_str(),
739 vsel.c_str(),
740 sitePath.GetText(),
741 siteAssetPath.c_str());
742 }
743
744 ///////////////////////////////////////////////////////////////////////////////
745
746 PcpErrorOpinionAtRelocationSourcePtr
New()747 PcpErrorOpinionAtRelocationSource::New()
748 {
749 return PcpErrorOpinionAtRelocationSourcePtr(
750 new PcpErrorOpinionAtRelocationSource);
751 }
752
PcpErrorOpinionAtRelocationSource()753 PcpErrorOpinionAtRelocationSource::PcpErrorOpinionAtRelocationSource() :
754 PcpErrorBase(PcpErrorType_OpinionAtRelocationSource)
755 {
756 }
757
~PcpErrorOpinionAtRelocationSource()758 PcpErrorOpinionAtRelocationSource::~PcpErrorOpinionAtRelocationSource()
759 {
760 }
761
762 // virtual
763 std::string
ToString() const764 PcpErrorOpinionAtRelocationSource::ToString() const
765 {
766 return TfStringPrintf("The layer @%s@ has an invalid opinion at the "
767 "relocation source path <%s>, which will be "
768 "ignored.",
769 layer->GetIdentifier().c_str(),
770 path.GetText());
771 }
772
773 ///////////////////////////////////////////////////////////////////////////////
774
775 PcpErrorPrimPermissionDeniedPtr
New()776 PcpErrorPrimPermissionDenied::New()
777 {
778 return PcpErrorPrimPermissionDeniedPtr(new PcpErrorPrimPermissionDenied);
779 }
780
PcpErrorPrimPermissionDenied()781 PcpErrorPrimPermissionDenied::PcpErrorPrimPermissionDenied() :
782 PcpErrorBase(PcpErrorType_PrimPermissionDenied)
783 {
784 }
785
~PcpErrorPrimPermissionDenied()786 PcpErrorPrimPermissionDenied::~PcpErrorPrimPermissionDenied()
787 {
788 }
789
790 // virtual
791 std::string
ToString() const792 PcpErrorPrimPermissionDenied::ToString() const
793 {
794 return TfStringPrintf("%s\n"
795 "will be ignored because:\n"
796 "%s\n"
797 "is private and overrides its opinions.",
798 TfStringify(site).c_str(),
799 TfStringify(privateSite).c_str());
800 }
801
802 ///////////////////////////////////////////////////////////////////////////////
803
804 PcpErrorPropertyPermissionDeniedPtr
New()805 PcpErrorPropertyPermissionDenied::New()
806 {
807 return PcpErrorPropertyPermissionDeniedPtr(
808 new PcpErrorPropertyPermissionDenied);
809 }
810
PcpErrorPropertyPermissionDenied()811 PcpErrorPropertyPermissionDenied::PcpErrorPropertyPermissionDenied() :
812 PcpErrorBase(PcpErrorType_PropertyPermissionDenied)
813 {
814 }
815
~PcpErrorPropertyPermissionDenied()816 PcpErrorPropertyPermissionDenied::~PcpErrorPropertyPermissionDenied()
817 {
818 }
819
820 // virtual
821 std::string
ToString() const822 PcpErrorPropertyPermissionDenied::ToString() const
823 {
824 return TfStringPrintf("The layer at @%s@ has an illegal opinion about "
825 "%s <%s> which is private across a reference, "
826 "inherit, or variant. Ignoring.",
827 layerPath.c_str(),
828 propType == SdfSpecTypeAttribute ?
829 "an attribute" : "a relationship",
830 propPath.GetText());
831 }
832
833 ///////////////////////////////////////////////////////////////////////////////
834
835 PcpErrorSublayerCyclePtr
New()836 PcpErrorSublayerCycle::New()
837 {
838 return PcpErrorSublayerCyclePtr(new PcpErrorSublayerCycle);
839 }
840
PcpErrorSublayerCycle()841 PcpErrorSublayerCycle::PcpErrorSublayerCycle() :
842 PcpErrorBase(PcpErrorType_SublayerCycle)
843 {
844 }
845
~PcpErrorSublayerCycle()846 PcpErrorSublayerCycle::~PcpErrorSublayerCycle()
847 {
848 }
849
850 // virtual
851 std::string
ToString() const852 PcpErrorSublayerCycle::ToString() const
853 {
854 return TfStringPrintf("Sublayer hierarchy with root layer @%s@ has cycles. "
855 "Detected when layer @%s@ was seen in the layer "
856 "stack for the second time.",
857 layer->GetIdentifier().c_str(),
858 sublayer->GetIdentifier().c_str());
859 }
860
861 ///////////////////////////////////////////////////////////////////////////////
862
863 PcpErrorTargetPermissionDeniedPtr
New()864 PcpErrorTargetPermissionDenied::New()
865 {
866 return PcpErrorTargetPermissionDeniedPtr(
867 new PcpErrorTargetPermissionDenied);
868 }
869
PcpErrorTargetPermissionDenied()870 PcpErrorTargetPermissionDenied::PcpErrorTargetPermissionDenied()
871 : PcpErrorTargetPathBase(PcpErrorType_TargetPermissionDenied)
872 {
873 }
874
~PcpErrorTargetPermissionDenied()875 PcpErrorTargetPermissionDenied::~PcpErrorTargetPermissionDenied()
876 {
877 }
878
879 // virtual
880 std::string
ToString() const881 PcpErrorTargetPermissionDenied::ToString() const
882 {
883 TF_VERIFY(ownerSpecType == SdfSpecTypeAttribute ||
884 ownerSpecType == SdfSpecTypeRelationship);
885 return TfStringPrintf(
886 "The %s <%s> from <%s> in layer @%s@ targets an object that is "
887 "private on the far side of a reference or inherit. This %s "
888 "will be ignored.",
889 (ownerSpecType == SdfSpecTypeAttribute
890 ? "attribute connection" : "relationship target"),
891 targetPath.GetText(),
892 owningPath.GetText(),
893 layer->GetIdentifier().c_str(),
894 (ownerSpecType == SdfSpecTypeAttribute
895 ? "connection" : "target"));
896 }
897
898 ///////////////////////////////////////////////////////////////////////////////
899
900 PcpErrorUnresolvedPrimPathPtr
New()901 PcpErrorUnresolvedPrimPath::New()
902 {
903 return PcpErrorUnresolvedPrimPathPtr(new PcpErrorUnresolvedPrimPath);
904 }
905
PcpErrorUnresolvedPrimPath()906 PcpErrorUnresolvedPrimPath::PcpErrorUnresolvedPrimPath() :
907 PcpErrorBase(PcpErrorType_UnresolvedPrimPath)
908 {
909 }
910
~PcpErrorUnresolvedPrimPath()911 PcpErrorUnresolvedPrimPath::~PcpErrorUnresolvedPrimPath()
912 {
913 }
914
915 // virtual
916 std::string
ToString() const917 PcpErrorUnresolvedPrimPath::ToString() const
918 {
919 return TfStringPrintf("Unresolved %s path <%s> on prim %s.",
920 TfEnum::GetDisplayName(arcType).c_str(),
921 unresolvedPath.GetText(),
922 TfStringify(site).c_str());
923 }
924
925 ///////////////////////////////////////////////////////////////////////////////
926
927 void
PcpRaiseErrors(const PcpErrorVector & errors)928 PcpRaiseErrors(const PcpErrorVector &errors)
929 {
930 TF_FOR_ALL(err, errors) {
931 TF_RUNTIME_ERROR("%s", (*err)->ToString().c_str());
932 }
933 }
934
935 PXR_NAMESPACE_CLOSE_SCOPE
936