Skip to content

Conversation

@Lctrs
Copy link

@Lctrs Lctrs commented Mar 23, 2017

Goal of this exception is to be catched by the SerializerListener in php-xapi/lrs-bundle to throw a BadRequestHttpException with a specific message.

@Lctrs
Copy link
Author

Lctrs commented Mar 23, 2017

Why this ?

It seems logical to me that our serializer implementations throw an exception if they try to deserialize a statement at a version they don't support.

This will potentially prevent the Symfony Serializer to throw more obscure exceptions, while this exception make the root of the problem pretty clear.

If we make this check after the SerializationListener has done its job in our LrsBundle, we can potentially never reach this check because of the said possible problems that can occurs during the deserialization process because of the version mismatch.

WDYT @xabbuh ?

@xabbuh
Copy link
Contributor

xabbuh commented Mar 24, 2017

Sounds like a good idea to me. But what do you think if we move this exception to the php-xapi/exception package? It will probably prove to be useful in other contexts too (and I don't think we need a specific implementation here).

@xabbuh
Copy link
Contributor

xabbuh commented Mar 24, 2017

We will also need to update the changelog.

@Lctrs
Copy link
Author

Lctrs commented Mar 24, 2017

Why not. It might be useful in the repository part too.

@Lctrs
Copy link
Author

Lctrs commented Mar 24, 2017

What parent exception should it extend then @xabbuh ?

@xabbuh
Copy link
Contributor

xabbuh commented Mar 25, 2017

Do we want it to extend another extension?

@Lctrs
Copy link
Author

Lctrs commented Mar 26, 2017

Having it extending \InvalidArgumentException seems the more logical to me.

@xabbuh
Copy link
Contributor

xabbuh commented Mar 29, 2017

One thing that still bothers me: We currently only cover the deserialization part. What if at some point the spec introduces breaking changes which we would need to cover in the model package? From the outside the object might still be a Statement instance, but it may be composed in other ways. Making the new generic UnsupportedStatementVersionException extend the StatementDeserializationException will block us from throwing a similar one during normalization. I think we should somehow reflect this in the exception's class name.

@Lctrs
Copy link
Author

Lctrs commented Mar 29, 2017

See php-xapi/exception#1 :)

xabbuh added a commit to php-xapi/exception that referenced this pull request Mar 29, 2017
This PR was squashed before being merged into the 0.1.x-dev branch (closes #1).

Discussion
----------

Add an exception for unsupported statement version

Replace php-xapi/serializer#37

Commits
-------

e43c0ac Add an exception for unsupported statement version
@xabbuh
Copy link
Contributor

xabbuh commented Mar 29, 2017

I thought about this once more and I think we should not mix low-level exceptions (like the ones from the serializer package) with high-level exceptions (the exceptions from the exceptions package). Instead, it's the responsibility of an LRS or the client library to map low-level to high-level exceptions. Therefore, I think we should still merge this PR, but with a slightly different exception name (by the way, php-xapi/exception#1 is merged ;)).

@Lctrs
Copy link
Author

Lctrs commented Mar 29, 2017

I don't see the value of this.

In the LrsBundle, we don't map low-level to high-level exceptions but we catch our exceptions - whatever library they are coming from - and throw the good HttpException from Symfony according to the spec.

@xabbuh
Copy link
Contributor

xabbuh commented Mar 29, 2017

Good point, I didn't think of some of other other exceptions. Can you then update the exception namespace to use our new one and also add php-xapi/exception to the required packages?

@Lctrs Lctrs changed the title Add an exception to be thrown when the version of the serialized statement is not supported Add support for UnsupportedStatementVersionException from php-xapi/exception Mar 29, 2017
@Lctrs
Copy link
Author

Lctrs commented Mar 29, 2017

@xabbuh Done.

@xabbuh
Copy link
Contributor

xabbuh commented Mar 29, 2017

Thank you @Lctrs.

@xabbuh xabbuh closed this in a3697e0 Mar 29, 2017
@Lctrs Lctrs deleted the feature/unsupported-version-exception branch March 29, 2017 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants